Browse Source

Update db.InsertNav

SqlSugar5
sunkaixuan 2 years ago
parent
commit
90c4df5cc0
  1. 13
      Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/InsertNavProvider.cs
  2. 49
      Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/InsertNavTask.cs

13
Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/InsertNavProvider.cs

@ -18,6 +18,7 @@ namespace SqlSugar
public SqlSugarProvider _Context { get; set; }
public NavigateType? _NavigateType { get; set; }
public bool IsFirst { get; set; }
public InsertNavOptions _navOptions { get; set; }
public InsertNavProvider<Root, Root> AsNav()
{
@ -29,6 +30,18 @@ namespace SqlSugar
_ParentPkColumn=this._Context.EntityMaintenance.GetEntityInfo<Root>().Columns.First(it=>it.IsPrimarykey)
};
}
public InsertNavProvider<Root, TChild> ThenInclude<TChild>(Expression<Func<T, TChild>> expression,InsertNavOptions options) where TChild : class, new()
{
_navOptions = options;
return _ThenInclude(expression);
}
public InsertNavProvider<Root, TChild> ThenInclude<TChild>(Expression<Func<T, List<TChild>>> expression, InsertNavOptions options) where TChild : class, new()
{
_navOptions = options;
return _ThenInclude(expression);
}
public InsertNavProvider<Root, TChild> ThenInclude<TChild>(Expression<Func<T, TChild>> expression) where TChild : class, new()
{
return _ThenInclude(expression);

49
Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/InsertNavTask.cs

@ -31,6 +31,25 @@ namespace SqlSugar
result.Context = this.Context;
return result;
}
public InsertNavTask<Root, TChild> Include<TChild>(Expression<Func<Root, TChild>> expression,InsertNavOptions options) where TChild : class, new()
{
this.Context = insertNavProvider._Context;
InsertNavTask<Root, TChild> result = new InsertNavTask<Root, TChild>();
Func<InsertNavProvider<Root, TChild>> func = () => insertNavProvider.ThenInclude(expression, options);
result.PreFunc = func;
result.Context = this.Context;
return result;
}
public InsertNavTask<Root, TChild> Include<TChild>(Expression<Func<Root, List<TChild>>> expression, InsertNavOptions options) where TChild : class, new()
{
this.Context = insertNavProvider._Context;
InsertNavTask<Root, TChild> result = new InsertNavTask<Root, TChild>();
Func<InsertNavProvider<Root, TChild>> func = () => insertNavProvider.ThenInclude(expression, options);
result.PreFunc = func;
result.Context = this.Context;
return result;
}
}
public class InsertNavTask<Root, T> where T : class, new() where Root : class, new()
{
@ -60,6 +79,36 @@ namespace SqlSugar
{
return AsNav().ThenInclude(expression);
}
public InsertNavTask<Root, TChild> ThenInclude<TChild>(Expression<Func<T, TChild>> expression,InsertNavOptions options) where TChild : class, new()
{
InsertNavTask<Root, TChild> result = new InsertNavTask<Root, TChild>();
Func<InsertNavProvider<Root, TChild>> func = () => PreFunc().ThenInclude(expression,options);
result.PreFunc = func;
result.Context = this.Context;
return result;
}
public InsertNavTask<Root, TChild> ThenInclude<TChild>(Expression<Func<T, List<TChild>>> expression, InsertNavOptions options) where TChild : class, new()
{
InsertNavTask<Root, TChild> result = new InsertNavTask<Root, TChild>();
Func<InsertNavProvider<Root, TChild>> func = () => PreFunc().ThenInclude(expression, options);
result.PreFunc = func;
result.Context = this.Context;
return result;
}
public InsertNavTask<Root, TChild> Include<TChild>(Expression<Func<Root, TChild>> expression, InsertNavOptions options) where TChild : class, new()
{
return AsNav().ThenInclude(expression, options);
}
public InsertNavTask<Root, TChild> Include<TChild>(Expression<Func<Root, List<TChild>>> expression, InsertNavOptions options) where TChild : class, new()
{
return AsNav().ThenInclude(expression, options);
}
public bool ExecuteCommand()
{
var hasTran = this.Context.Ado.Transaction != null;

Loading…
Cancel
Save