mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-04 20:57:58 +08:00
Synchronization code
This commit is contained in:
parent
dd10f26612
commit
c62d7cf059
@ -0,0 +1,53 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SqlSugar
|
||||||
|
{
|
||||||
|
public class DeleteNavMethodInfo
|
||||||
|
{
|
||||||
|
internal object MethodInfos { get; set; }
|
||||||
|
internal SqlSugarProvider Context { get; set; }
|
||||||
|
|
||||||
|
public DeleteNavMethodInfo IncludeByNameString(string navMemberName, UpdateNavOptions updateNavOptions = null)
|
||||||
|
{
|
||||||
|
var type = MethodInfos.GetType().GetGenericArguments()[0];
|
||||||
|
var entityInfo = this.Context.EntityMaintenance.GetEntityInfo(type);
|
||||||
|
Type properyItemType;
|
||||||
|
bool isList;
|
||||||
|
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out properyItemType, out isList);
|
||||||
|
var method = this.MethodInfos.GetType().GetMyMethod("Include", 2, isList)
|
||||||
|
.MakeGenericMethod(properyItemType);
|
||||||
|
var obj = method.Invoke(this.MethodInfos, new object[] { exp, updateNavOptions });
|
||||||
|
this.MethodInfos = obj;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public DeleteNavMethodInfo ThenIncludeByNameString(string navMemberName, UpdateNavOptions updateNavOptions = null)
|
||||||
|
{
|
||||||
|
var type = MethodInfos.GetType().GetGenericArguments()[1];
|
||||||
|
var entityInfo = this.Context.EntityMaintenance.GetEntityInfo(type);
|
||||||
|
Type properyItemType;
|
||||||
|
bool isList;
|
||||||
|
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out properyItemType, out isList);
|
||||||
|
var method = this.MethodInfos.GetType().GetMyMethod("ThenInclude", 2, isList)
|
||||||
|
.MakeGenericMethod(properyItemType);
|
||||||
|
var obj = method.Invoke(this.MethodInfos, new object[] { exp, updateNavOptions });
|
||||||
|
this.MethodInfos = obj;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public async Task<bool> ExecuteCommandAsync()
|
||||||
|
{
|
||||||
|
if (Context == null) return false;
|
||||||
|
var result = MethodInfos.GetType().GetMethod("ExecuteCommandAsync").Invoke(MethodInfos, new object[] { });
|
||||||
|
return await (Task<bool>)result;
|
||||||
|
}
|
||||||
|
public bool ExecuteCommand()
|
||||||
|
{
|
||||||
|
if (Context == null) return false;
|
||||||
|
var result = MethodInfos.GetType().GetMethod("ExecuteCommand").Invoke(MethodInfos, new object[] { });
|
||||||
|
return (bool)result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -22,6 +22,20 @@ namespace SqlSugar
|
|||||||
result.Context = this.Context;
|
result.Context = this.Context;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
public DeleteNavMethodInfo IncludeByNameString(string navMemberName, UpdateNavOptions updateNavOptions = null)
|
||||||
|
{
|
||||||
|
DeleteNavMethodInfo result = new DeleteNavMethodInfo();
|
||||||
|
result.Context = deleteNavProvider._Context;
|
||||||
|
var entityInfo = result.Context.EntityMaintenance.GetEntityInfo<T>();
|
||||||
|
Type properyItemType;
|
||||||
|
bool isList;
|
||||||
|
Expression exp = UtilMethods.GetIncludeExpression(navMemberName, entityInfo, out properyItemType, out isList);
|
||||||
|
var method = this.GetType().GetMyMethod("Include", 2, isList)
|
||||||
|
.MakeGenericMethod(properyItemType);
|
||||||
|
var obj = method.Invoke(this, new object[] { exp, updateNavOptions });
|
||||||
|
result.MethodInfos = obj;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
public DeleteNavTask<Root, TChild> Include<TChild>(Expression<Func<Root, List<TChild>>> expression) where TChild : class, new()
|
public DeleteNavTask<Root, TChild> Include<TChild>(Expression<Func<Root, List<TChild>>> expression) where TChild : class, new()
|
||||||
{
|
{
|
||||||
this.Context = deleteNavProvider._Context;
|
this.Context = deleteNavProvider._Context;
|
||||||
@ -50,6 +64,18 @@ namespace SqlSugar
|
|||||||
result.Context = this.Context;
|
result.Context = this.Context;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
public DeleteNavTask<Root, TChild> ThenInclude<TChild>(Expression<Func<T, TChild>> expression, DeleteNavOptions deleteNavOptions) where TChild : class, new()
|
||||||
|
{
|
||||||
|
DeleteNavTask<Root, TChild> result = new DeleteNavTask<Root, TChild>();
|
||||||
|
Func<DeleteNavProvider<Root, TChild>> func = () => {
|
||||||
|
var dev = PreFunc();
|
||||||
|
dev.deleteNavOptions = deleteNavOptions;
|
||||||
|
return dev.ThenInclude(expression);
|
||||||
|
};
|
||||||
|
result.PreFunc = func;
|
||||||
|
result.Context = this.Context;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
public DeleteNavTask<Root, TChild> ThenInclude<TChild>(Expression<Func<T, List<TChild>>> expression) where TChild : class, new()
|
public DeleteNavTask<Root, TChild> ThenInclude<TChild>(Expression<Func<T, List<TChild>>> expression) where TChild : class, new()
|
||||||
{
|
{
|
||||||
DeleteNavTask<Root, TChild> result = new DeleteNavTask<Root, TChild>();
|
DeleteNavTask<Root, TChild> result = new DeleteNavTask<Root, TChild>();
|
||||||
@ -74,6 +100,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return AsNav().ThenInclude(expression);
|
return AsNav().ThenInclude(expression);
|
||||||
}
|
}
|
||||||
|
public DeleteNavTask<Root, TChild> Include<TChild>(Expression<Func<Root, TChild>> expression, DeleteNavOptions options) where TChild : class, new()
|
||||||
|
{
|
||||||
|
return AsNav().ThenInclude(expression,options);
|
||||||
|
}
|
||||||
public DeleteNavTask<Root, TChild> Include<TChild>(Expression<Func<Root, List<TChild>>> expression) where TChild : class, new()
|
public DeleteNavTask<Root, TChild> Include<TChild>(Expression<Func<Root, List<TChild>>> expression) where TChild : class, new()
|
||||||
{
|
{
|
||||||
return AsNav().ThenInclude(expression);
|
return AsNav().ThenInclude(expression);
|
||||||
|
@ -85,6 +85,7 @@
|
|||||||
<Compile Include="Abstract\DbMaintenanceProvider\Methods.cs" />
|
<Compile Include="Abstract\DbMaintenanceProvider\Methods.cs" />
|
||||||
<Compile Include="Abstract\DbMaintenanceProvider\Properties.cs" />
|
<Compile Include="Abstract\DbMaintenanceProvider\Properties.cs" />
|
||||||
<Compile Include="Abstract\AdoProvider\AdoProvider.cs" />
|
<Compile Include="Abstract\AdoProvider\AdoProvider.cs" />
|
||||||
|
<Compile Include="Abstract\DeleteProvider\DeleteNavMethodInfo.cs" />
|
||||||
<Compile Include="Abstract\DeleteProvider\LogicDeleteProvider.cs" />
|
<Compile Include="Abstract\DeleteProvider\LogicDeleteProvider.cs" />
|
||||||
<Compile Include="Abstract\DeleteProvider\SplitTableDeleteByObjectProvider.cs" />
|
<Compile Include="Abstract\DeleteProvider\SplitTableDeleteByObjectProvider.cs" />
|
||||||
<Compile Include="Abstract\DeleteProvider\SplitTableDeleteProvider.cs" />
|
<Compile Include="Abstract\DeleteProvider\SplitTableDeleteProvider.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user