Update ConfigQuery

This commit is contained in:
sunkaixuan 2022-05-22 14:55:56 +08:00
parent 4cb5bfa326
commit c990d44d64

View File

@ -10,16 +10,18 @@ namespace SqlSugar
{
public SqlSugarProvider Context { get; set; }
public void SetTable<T>(Expression<Func<T, object>> keyExpression, Expression<Func<T, object>> valueTextExpression, string uniqueCode = null, Expression<Func<T, object>> whereExpression=null)
{
lock (SqlFuncExtendsion.TableInfos)
{
var entity = this.Context.EntityMaintenance.GetEntityInfo<T>();
ExpressionContext context = new ExpressionContext();
var query = Context.Queryable<T>().QueryBuilder;
var keyValue= query.GetExpressionValue(keyExpression, ResolveExpressType.FieldSingle).GetString();
var keyValue = query.GetExpressionValue(keyExpression, ResolveExpressType.FieldSingle).GetString();
var ValueValue = query.GetExpressionValue(valueTextExpression, ResolveExpressType.FieldSingle).GetString();
string where = null;
if (whereExpression != null)
{
where=query.GetExpressionValue(whereExpression, ResolveExpressType.WhereSingle).GetResultString();
where = query.GetExpressionValue(whereExpression, ResolveExpressType.WhereSingle).GetResultString();
}
context.MappingTables = this.Context.MappingTables;
if (!SqlFuncExtendsion.TableInfos.Any(y => y.Type == typeof(T) && y.Code == uniqueCode))
@ -40,6 +42,7 @@ namespace SqlSugar
Check.Exception(true, "SetKeyValue error , entity & uniqueCode already exist");
}
}
}
public void SetTable<T>(Expression<Func<T, object>> key, Expression<Func<T, object>> value)
{
SetTable<T>(key,value, null,null);