Browse Source

Add insert&update&delerte nav empty api

pull/19/head
sunkaixuan 2 years ago
parent
commit
25b008c041
  1. 9
      Src/Asp.Net/SqlServerTest/UnitTest/UCustom012.cs
  2. 25
      Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavProvider.cs
  3. 25
      Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/InsertNavProvider.cs
  4. 25
      Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/UpdateInsert.cs
  5. 33
      Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarProvider.cs
  6. 24
      Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarScopeProvider.cs
  7. 9
      Src/Asp.Net/SqlSugar/Interface/ISqlSugarClient.cs
  8. 3
      Src/Asp.Net/SqlSugar/SqlSugar.csproj
  9. 27
      Src/Asp.Net/SqlSugar/SqlSugarClient.cs
  10. 26
      Src/Asp.Net/SqlSugar/SqlSugarScope.cs

9
Src/Asp.Net/SqlServerTest/UnitTest/UCustom012.cs

@ -105,6 +105,15 @@ namespace OrmTest
.ToList(); .ToList();
//功能开发中
db.InsertNav(list3)
.ThenInclude(z1 => z1.SchoolA)
.ThenInclude(z1 => z1.RoomList)
.AsNav()
.ThenInclude(z1 => z1.Books);
var list3_1 = db.Queryable<StudentA>() var list3_1 = db.Queryable<StudentA>()
.Includes(x => x.Books.MappingField(z=>z.Names,()=>x.Name).ToList()) .Includes(x => x.Books.MappingField(z=>z.Names,()=>x.Name).ToList())

25
Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/DeleteNavProvider.cs

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public class DeleteNavProvider<Root,T>
{
public List<Root> Roots { get; set; }
public DeleteNavProvider<Root,TChild> ThenInclude<TChild>(Expression<Func<T,TChild>> expression)
{
return null;
}
public DeleteNavProvider<Root,Root> AsNav()
{
return null;
}
}
}

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

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public class InsertNavProvider<Root,T>
{
public List<Root> Roots { get; set; }
public InsertNavProvider<Root,TChild> ThenInclude<TChild>(Expression<Func<T,TChild>> expression)
{
return null;
}
public InsertNavProvider<Root,Root> AsNav()
{
return null;
}
}
}

25
Src/Asp.Net/SqlSugar/Abstract/ExecuteNavProvider/UpdateInsert.cs

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SqlSugar
{
public class UpdateNavProvider<Root,T>
{
public List<Root> Roots { get; set; }
public UpdateNavProvider<Root,TChild> ThenInclude<TChild>(Expression<Func<T,TChild>> expression)
{
return null;
}
public UpdateNavProvider<Root,Root> AsNav()
{
return null;
}
}
}

33
Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarProvider.cs

@ -889,6 +889,39 @@ namespace SqlSugar
} }
#endregion #endregion
#region Nav CUD
public InsertNavProvider<T, T> InsertNav<T>(T data)
{
return InsertNav(new List<T>() { data });
}
public InsertNavProvider<T, T> InsertNav<T>(List<T> datas)
{
var result = new InsertNavProvider<T, T>();
result.Roots = datas;
return result;
}
public DeleteNavProvider<T, T> DeleteNav<T>(T data)
{
return DeleteNav(new List<T>() { data });
}
public DeleteNavProvider<T, T> DeleteNav<T>(List<T> datas)
{
var result = new DeleteNavProvider<T, T>();
result.Roots = datas;
return result;
}
public UpdateNavProvider<T, T> UpdateNav<T>(T data)
{
return UpdateNav(new List<T>() { data });
}
public UpdateNavProvider<T, T> UpdateNav<T>(List<T> datas)
{
var result = new UpdateNavProvider<T, T>();
result.Roots = datas;
return result;
}
#endregion
#region DbFirst #region DbFirst
public virtual IDbFirst DbFirst public virtual IDbFirst DbFirst
{ {

24
Src/Asp.Net/SqlSugar/Abstract/SugarProvider/SqlSugarScopeProvider.cs

@ -678,6 +678,30 @@ namespace SqlSugar
{ {
return ScopedContext.Saveable(saveObject); return ScopedContext.Saveable(saveObject);
} }
public InsertNavProvider<T, T> InsertNav<T>(T data)
{
return ScopedContext.InsertNav(data);
}
public InsertNavProvider<T, T> InsertNav<T>(List<T> datas)
{
return ScopedContext.InsertNav(datas);
}
public DeleteNavProvider<T, T> DeleteNav<T>(T data)
{
return ScopedContext.DeleteNav(data);
}
public DeleteNavProvider<T, T> DeleteNav<T>(List<T> datas)
{
return ScopedContext.DeleteNav(datas);
}
public UpdateNavProvider<T, T> UpdateNav<T>(T data)
{
return ScopedContext.UpdateNav(data);
}
public UpdateNavProvider<T, T> UpdateNav<T>(List<T> datas)
{
return ScopedContext.UpdateNav(datas);
}
#endregion #endregion
} }
} }

9
Src/Asp.Net/SqlSugar/Interface/ISqlSugarClient.cs

@ -202,5 +202,14 @@ namespace SqlSugar
Task ThenMapperAsync<T>(IEnumerable<T> list, Func<T,Task> action); Task ThenMapperAsync<T>(IEnumerable<T> list, Func<T,Task> action);
#endregion #endregion
#region Nav CUD
InsertNavProvider<T, T> InsertNav<T>(T data);
InsertNavProvider<T, T> InsertNav<T>(List<T> datas);
DeleteNavProvider<T, T> DeleteNav<T>(T data);
DeleteNavProvider<T, T> DeleteNav<T>(List<T> datas);
UpdateNavProvider<T, T> UpdateNav<T>(T data);
UpdateNavProvider<T, T> UpdateNav<T>(List<T> datas);
#endregion
} }
} }

3
Src/Asp.Net/SqlSugar/SqlSugar.csproj

@ -89,6 +89,9 @@
<Compile Include="Abstract\DeleteProvider\SplitTableDeleteByObjectProvider.cs" /> <Compile Include="Abstract\DeleteProvider\SplitTableDeleteByObjectProvider.cs" />
<Compile Include="Abstract\DeleteProvider\SplitTableDeleteProvider.cs" /> <Compile Include="Abstract\DeleteProvider\SplitTableDeleteProvider.cs" />
<Compile Include="Abstract\EntityMaintenance\EntityMaintenance.cs" /> <Compile Include="Abstract\EntityMaintenance\EntityMaintenance.cs" />
<Compile Include="Abstract\ExecuteNavProvider\DeleteNavProvider.cs" />
<Compile Include="Abstract\ExecuteNavProvider\UpdateInsert.cs" />
<Compile Include="Abstract\ExecuteNavProvider\InsertNavProvider.cs" />
<Compile Include="Abstract\ExpressionableProvider\Expressionable.cs" /> <Compile Include="Abstract\ExpressionableProvider\Expressionable.cs" />
<Compile Include="Abstract\FastestProvider\FastBuilder.cs" /> <Compile Include="Abstract\FastestProvider\FastBuilder.cs" />
<Compile Include="Abstract\FastestProvider\FastestProvider.cs" /> <Compile Include="Abstract\FastestProvider\FastestProvider.cs" />

27
Src/Asp.Net/SqlSugar/SqlSugarClient.cs

@ -153,6 +153,33 @@ namespace SqlSugar
#region Queryable #region Queryable
#region Nav CUD
public InsertNavProvider<T, T> InsertNav<T>(T data)
{
return this.Context.InsertNav(data);
}
public InsertNavProvider<T, T> InsertNav<T>(List<T> datas)
{
return this.Context.InsertNav(datas);
}
public DeleteNavProvider<T, T> DeleteNav<T>(T data)
{
return this.Context.DeleteNav(data);
}
public DeleteNavProvider<T, T> DeleteNav<T>(List<T> datas)
{
return this.Context.DeleteNav(datas);
}
public UpdateNavProvider<T, T> UpdateNav<T>(T data)
{
return this.Context.UpdateNav(data);
}
public UpdateNavProvider<T, T> UpdateNav<T>(List<T> datas)
{
return this.Context.UpdateNav(datas);
}
#endregion
#region Union #region Union
public ISugarQueryable<T> Union<T>(List<ISugarQueryable<T>> queryables) where T : class, new() public ISugarQueryable<T> Union<T>(List<ISugarQueryable<T>> queryables) where T : class, new()
{ {

26
Src/Asp.Net/SqlSugar/SqlSugarScope.cs

@ -723,5 +723,31 @@ namespace SqlSugar
{ {
return ScopedContext.DeleteableWithAttr<T>(deleteObjs); return ScopedContext.DeleteableWithAttr<T>(deleteObjs);
} }
public InsertNavProvider<T, T> InsertNav<T>(T data)
{
return ScopedContext.InsertNav(data);
}
public InsertNavProvider<T, T> InsertNav<T>(List<T> datas)
{
return ScopedContext.InsertNav(datas);
}
public DeleteNavProvider<T, T> DeleteNav<T>(T data)
{
return ScopedContext.DeleteNav(data);
}
public DeleteNavProvider<T, T> DeleteNav<T>(List<T> datas)
{
return ScopedContext.DeleteNav(datas);
}
public UpdateNavProvider<T, T> UpdateNav<T>(T data)
{
return ScopedContext.UpdateNav(data);
}
public UpdateNavProvider<T, T> UpdateNav<T>(List<T> datas)
{
return ScopedContext.UpdateNav(datas);
}
} }
} }

Loading…
Cancel
Save