Update .net core project

This commit is contained in:
sunkaixuan
2022-06-15 22:16:55 +08:00
parent dc00b728bf
commit 40ba3ea553
5 changed files with 92 additions and 0 deletions

View File

@@ -17,6 +17,11 @@ namespace SqlSugar
express.IfTrue,
express.IfFalse
};
if (IsBoolMember(express))
{
Expression trueValue = Expression.Constant(true);
args[0]= ExpressionBuilderHelper.CreateExpression(express.Test, trueValue, ExpressionType.And);
}
var isLeft = parameter.IsLeft;
MethodCallExpressionModel model = new MethodCallExpressionModel();
model.Args = new List<MethodCallExpressionArgs>();
@@ -40,5 +45,10 @@ namespace SqlSugar
break;
}
}
private static bool IsBoolMember(ConditionalExpression express)
{
return express.Test is MemberExpression && (express.Test as MemberExpression).Expression is ParameterExpression;
}
}
}

View File

@@ -24,6 +24,13 @@ namespace SqlSugar
SqlSugarScopeProvider GetConnectionScope(dynamic configId);
SqlSugarProvider GetConnectionWithAttr<T>();
SqlSugarScopeProvider GetConnectionScopeWithAttr<T>();
ISugarQueryable<T> QueryableWithAttr<T>();
IInsertable<T> InsertableWithAttr<T>(T insertObj) where T : class, new();
IInsertable<T> InsertableWithAttr<T>(List<T> insertObjs) where T : class, new();
IUpdateable<T> UpdateableWithAttr<T>(T updateObj) where T : class, new();
IUpdateable<T> UpdateableWithAttr<T>(List<T> updateObjs) where T : class, new();
IDeleteable<T> DeleteableWithAttr<T>(T deleteObjs) where T : class, new();
IDeleteable<T> DeleteableWithAttr<T>(List<T> deleteObjs) where T : class, new();
bool IsAnyConnection(dynamic configId);
void Close();

View File

@@ -1243,5 +1243,36 @@ namespace SqlSugar
this.CurrentConnectionConfig = Tenant.ConnectionConfig;
}
#endregion
#region Tenant Crud
public ISugarQueryable<T> QueryableWithAttr<T>()
{
return this.GetConnectionWithAttr<T>().Queryable<T>();
}
public IInsertable<T> InsertableWithAttr<T>(T insertObj) where T : class, new()
{
return this.GetConnectionWithAttr<T>().Insertable(insertObj);
}
public IInsertable<T> InsertableWithAttr<T>(List<T> insertObjs) where T : class, new()
{
return this.GetConnectionWithAttr<T>().Insertable(insertObjs);
}
public IUpdateable<T> UpdateableWithAttr<T>(T updateObj) where T : class, new()
{
return this.GetConnectionWithAttr<T>().Updateable(updateObj);
}
public IUpdateable<T> UpdateableWithAttr<T>(List<T> updateObjs) where T : class, new()
{
return this.GetConnectionWithAttr<T>().Updateable(updateObjs);
}
public IDeleteable<T> DeleteableWithAttr<T>(T deleteObject) where T : class, new()
{
return this.GetConnectionWithAttr<T>().Deleteable(deleteObject);
}
public IDeleteable<T> DeleteableWithAttr<T>(List<T> deleteObjects) where T : class, new()
{
return this.GetConnectionWithAttr<T>().Deleteable(deleteObjects);
}
#endregion
}
}

View File

@@ -695,5 +695,33 @@ namespace SqlSugar
{
return ScopedContext.ThenMapperAsync(list, action);
}
public ISugarQueryable<T> QueryableWithAttr<T>()
{
return ScopedContext.QueryableWithAttr<T>();
}
public IInsertable<T> InsertableWithAttr<T>(T insertObj) where T : class, new()
{
return ScopedContext.InsertableWithAttr<T>(insertObj);
}
public IInsertable<T> InsertableWithAttr<T>(List<T> insertObjs) where T : class, new()
{
return ScopedContext.InsertableWithAttr<T>(insertObjs);
}
public IUpdateable<T> UpdateableWithAttr<T>(T updateObj) where T : class, new()
{
return ScopedContext.UpdateableWithAttr<T>(updateObj);
}
public IUpdateable<T> UpdateableWithAttr<T>(List<T> updateObjs) where T : class, new()
{
return ScopedContext.UpdateableWithAttr<T>(updateObjs);
}
public IDeleteable<T> DeleteableWithAttr<T>(T deleteObj) where T : class, new()
{
return ScopedContext.DeleteableWithAttr<T>(deleteObj);
}
public IDeleteable<T> DeleteableWithAttr<T>(List<T> deleteObjs) where T : class, new()
{
return ScopedContext.DeleteableWithAttr<T>(deleteObjs);
}
}
}

View File

@@ -12,6 +12,22 @@ namespace SqlSugar
{
public class ExpressionBuilderHelper
{
/// <summary>
/// Create Expression
/// </summary>
public static Expression CreateExpression(Expression left, Expression value, ExpressionType type)
{
if (type == ExpressionType.Equal)
{
return Expression.Equal(left, Expression.Convert(value, left.Type));
}
else
{
//Not implemented, later used in writing
return Expression.Equal(left, Expression.Convert(value, left.Type));
}
}
public static Expression<Func<T, object>> CreateNewFields<T>(EntityInfo entity,List<string> propertyNames)
{
Type sourceType = typeof(T);