mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-17 05:29:33 +08:00
Synchronization code
This commit is contained in:
parent
7042880490
commit
c64d0b5b9a
@ -156,7 +156,7 @@ namespace SqlSugar
|
||||
};
|
||||
model.Args.Add(methodCallExpressionArgs);
|
||||
}
|
||||
else if (isFirst && isIIF && isIFFBoolMember&& (item as MemberExpression)?.Member?.Name=="HasValue")
|
||||
else if (isFirst && isIIF && isIFFBoolMember && (item as MemberExpression)?.Member?.Name == "HasValue")
|
||||
{
|
||||
var value = base.GetNewExpressionValue(item);
|
||||
var methodCallExpressionArgs = new MethodCallExpressionArgs()
|
||||
@ -167,9 +167,9 @@ namespace SqlSugar
|
||||
};
|
||||
model.Args.Add(methodCallExpressionArgs);
|
||||
}
|
||||
else if (name!=null && name != "MappingColumn" && !name.StartsWith("Row") &&ExpressionTool.GetMethodName(item)== "Format" && ExpressionTool.GetParameters(item).Count==0)
|
||||
else if (name != null && name != "MappingColumn" && !name.StartsWith("Row") && ExpressionTool.GetMethodName(item) == "Format" && ExpressionTool.GetParameters(item).Count == 0)
|
||||
{
|
||||
var value = ExpressionTool.DynamicInvoke(item);
|
||||
var value = ExpressionTool.DynamicInvoke(item);
|
||||
var p = AppendParameter(value);
|
||||
var methodCallExpressionArgs = new MethodCallExpressionArgs()
|
||||
{
|
||||
@ -265,6 +265,31 @@ namespace SqlSugar
|
||||
{
|
||||
model.Args.Add(GetMethodCallArgs(parameter, (item as MemberExpression).Expression));
|
||||
}
|
||||
else if (isBoolValue && isIIF && item is MemberExpression&&ExpressionTool.GetParameters(item).Count()==0)
|
||||
{
|
||||
var expValue = GetNewExpressionValue(item);
|
||||
expValue = this.Context.DbMehtods.Equals(new MethodCallExpressionModel()
|
||||
{
|
||||
Name = "Equals",
|
||||
Args = new List<MethodCallExpressionArgs>()
|
||||
{
|
||||
new MethodCallExpressionArgs(){
|
||||
IsMember=true,
|
||||
MemberName=expValue
|
||||
},
|
||||
new MethodCallExpressionArgs(){
|
||||
IsMember=true,
|
||||
MemberName= Context.DbMehtods.TrueValue()
|
||||
}
|
||||
}
|
||||
});
|
||||
model.Args.Add(new MethodCallExpressionArgs()
|
||||
{
|
||||
IsMember = false,
|
||||
MemberName = expValue,
|
||||
MemberValue = expValue
|
||||
});
|
||||
}
|
||||
else if (isBoolValue && isIIF && item is MemberExpression)
|
||||
{
|
||||
var argItem = GetMethodCallArgs(parameter, (item as MemberExpression).Expression);
|
||||
@ -277,7 +302,7 @@ namespace SqlSugar
|
||||
}
|
||||
model.Args.Add(argItem);
|
||||
}
|
||||
else if (name.IsIn("ListAny","ListAll") && item is LambdaExpression)
|
||||
else if (name.IsIn("ListAny", "ListAll") && item is LambdaExpression)
|
||||
{
|
||||
var sql = GetNewExpressionValue(item, ResolveExpressType.WhereMultiple);
|
||||
var lamExp = (item as LambdaExpression);
|
||||
@ -482,7 +507,7 @@ namespace SqlSugar
|
||||
}
|
||||
value = result;
|
||||
}
|
||||
else if (name.IsIn("Contains", "StartsWith", "EndsWith") &&item==args.Last()&& ExpressionTool.IsSqlParameterDbType(this.Context, args.First()))
|
||||
else if (!(item is ParameterExpression)&& name.IsIn("Contains", "StartsWith", "EndsWith") &&item==args.Last()&& ExpressionTool.IsSqlParameterDbType(this.Context, args.First()))
|
||||
{
|
||||
var myvalue = ExpressionTool.DynamicInvoke(args.Last());
|
||||
var parametre = ExpressionTool.GetParameterBySqlParameterDbType(this.Context.ParameterIndex,myvalue, this.Context, args.First());
|
||||
|
@ -13,6 +13,7 @@ namespace SqlSugar
|
||||
RepositoryType CopyNew<RepositoryType>() where RepositoryType : ISugarRepository;
|
||||
SimpleClient<ChangeType> Change<ChangeType>() where ChangeType : class, new();
|
||||
RepositoryType ChangeRepository<RepositoryType>() where RepositoryType : ISugarRepository ;
|
||||
RepositoryType ChangeRepository<RepositoryType>(IServiceProvider serviceProvider) where RepositoryType : ISugarRepository;
|
||||
IDeleteable<T> AsDeleteable();
|
||||
IInsertable<T> AsInsertable(List<T> insertObjs);
|
||||
IInsertable<T> AsInsertable(T insertObj);
|
||||
|
@ -79,11 +79,11 @@ namespace SqlSugar
|
||||
}
|
||||
public RepositoryType CopyNew<RepositoryType>(IServiceProvider serviceProvider) where RepositoryType : ISugarRepository
|
||||
{
|
||||
var instance = handleDependencies(typeof(RepositoryType), serviceProvider);
|
||||
var instance = handleDependencies(typeof(RepositoryType), serviceProvider,true);
|
||||
return (RepositoryType)instance;
|
||||
}
|
||||
|
||||
private object handleDependencies(Type type, IServiceProvider serviceProvider)
|
||||
private object handleDependencies(Type type, IServiceProvider serviceProvider,bool needNewCopy = false)
|
||||
{
|
||||
ConstructorInfo constructorInfo = null;
|
||||
var newInstanceType = type;
|
||||
@ -103,8 +103,7 @@ namespace SqlSugar
|
||||
object dependencyInstance = serviceProvider.GetService(type);
|
||||
if (dependencyInstance is ISugarRepository sugarRepository)
|
||||
{
|
||||
sugarRepository.Context = sugarRepository.Context.CopyNew();
|
||||
return sugarRepository;
|
||||
return setContext(sugarRepository, needNewCopy);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -130,7 +129,28 @@ namespace SqlSugar
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private ISugarRepository setContext(ISugarRepository sugarRepository,bool needNewCopy)
|
||||
{
|
||||
if (sugarRepository.Context != null)
|
||||
{
|
||||
if (needNewCopy)
|
||||
{
|
||||
sugarRepository.Context = sugarRepository.Context.CopyNew();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (needNewCopy)
|
||||
{
|
||||
sugarRepository.Context = this.Context.CopyNew();
|
||||
}
|
||||
else
|
||||
{
|
||||
sugarRepository.Context = this.Context;
|
||||
}
|
||||
}
|
||||
return sugarRepository;
|
||||
}
|
||||
private bool IsAssignableToBaseRepository(Type type)
|
||||
{
|
||||
var baseInterfaces = type.GetInterfaces();
|
||||
@ -169,6 +189,11 @@ namespace SqlSugar
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public RepositoryType ChangeRepository<RepositoryType>(IServiceProvider serviceProvider) where RepositoryType : ISugarRepository
|
||||
{
|
||||
var instance = handleDependencies(typeof(RepositoryType), serviceProvider, false);
|
||||
return (RepositoryType)instance;
|
||||
}
|
||||
public ISugarQueryable<T> AsQueryable()
|
||||
{
|
||||
return Context.Queryable<T>();
|
||||
|
Loading…
Reference in New Issue
Block a user