Delete nav

This commit is contained in:
sunkaixuan
2022-07-07 22:34:03 +08:00
parent 2711587ef7
commit f5ff95e996
5 changed files with 83 additions and 3 deletions

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public partial class DeleteNavProvider<Root, T> where T : class, new() where Root : class, new()
{
private void DeleteManyToMany<TChild>(string name, EntityColumnInfo nav) where TChild : class, new()
{
}
}
}

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public partial class DeleteNavProvider<Root, T> where T : class, new() where Root : class, new()
{
private void DeleteOneToMany<TChild>(string name, EntityColumnInfo nav) where TChild : class, new()
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public partial class DeleteNavProvider<Root, T> where T : class, new() where Root : class, new()
{
private void DeleteOneToOne<TChild>(string name, EntityColumnInfo nav) where TChild : class, new()
{
}
}
}

View File

@@ -7,15 +7,39 @@ using System.Threading.Tasks;
namespace SqlSugar
{
public class DeleteNavProvider<Root, T> where T : class, new() where Root : class, new()
public partial class DeleteNavProvider<Root, T> where T : class, new() where Root : class, new()
{
public SqlSugarProvider _Context { get; internal set; }
public List<Root> _Roots { get; set; }
public List<object> _ParentList { get; set; }
public List<object> _RootList { get; set; }
public EntityInfo _ParentEntity { get; set; }
public EntityColumnInfo _ParentPkColumn { get; set; }
public SqlSugarProvider _Context { get; set; }
public DeleteNavTask<Root, TChild> ThenInclude< TChild>(Expression<Func<Root, TChild>> expression)
where TChild : class, new()
{
throw new NotImplementedException();
var name = ExpressionTool.GetMemberName(expression);
var nav = this._ParentEntity.Columns.FirstOrDefault(x => x.PropertyName == name);
if (nav.Navigat == null)
{
Check.ExceptionEasy($"{name} no navigate attribute", $"{this._ParentEntity.EntityName}的属性{name}没有导航属性");
}
if (nav.Navigat.NavigatType == NavigateType.OneToOne || nav.Navigat.NavigatType == NavigateType.ManyToOne)
{
DeleteOneToOne<TChild>(name, nav);
}
else if (nav.Navigat.NavigatType == NavigateType.OneToMany)
{
DeleteOneToMany<TChild>(name, nav);
}
else
{
DeleteManyToMany<TChild>(name, nav);
}
return null;
}
public DeleteNavTask<Root, TChild> ThenInclude<TChild>(Expression<Func<Root, List<TChild>>> expression)
where TChild : class, new()
{

View File

@@ -89,6 +89,9 @@
<Compile Include="Abstract\DeleteProvider\SplitTableDeleteByObjectProvider.cs" />
<Compile Include="Abstract\DeleteProvider\SplitTableDeleteProvider.cs" />
<Compile Include="Abstract\EntityMaintenance\EntityMaintenance.cs" />
<Compile Include="Abstract\ExecuteNavProvider\DeleteNavManyToMany.cs" />
<Compile Include="Abstract\ExecuteNavProvider\DeleteNavOneToMany.cs" />
<Compile Include="Abstract\ExecuteNavProvider\DeleteNavOneToOne.cs" />
<Compile Include="Abstract\ExecuteNavProvider\DeleteNavProvider.cs" />
<Compile Include="Abstract\ExecuteNavProvider\InsertNavProviderHelper.cs" />
<Compile Include="Abstract\ExecuteNavProvider\InsertNavProviderOneToMany.cs" />