mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-24 07:22:57 +08:00
Update ConfigQuery
This commit is contained in:
parent
4cb5bfa326
commit
c990d44d64
@ -10,16 +10,18 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public SqlSugarProvider Context { get; set; }
|
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)
|
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>();
|
var entity = this.Context.EntityMaintenance.GetEntityInfo<T>();
|
||||||
ExpressionContext context = new ExpressionContext();
|
ExpressionContext context = new ExpressionContext();
|
||||||
var query = Context.Queryable<T>().QueryBuilder;
|
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();
|
var ValueValue = query.GetExpressionValue(valueTextExpression, ResolveExpressType.FieldSingle).GetString();
|
||||||
string where = null;
|
string where = null;
|
||||||
if (whereExpression != null)
|
if (whereExpression != null)
|
||||||
{
|
{
|
||||||
where=query.GetExpressionValue(whereExpression, ResolveExpressType.WhereSingle).GetResultString();
|
where = query.GetExpressionValue(whereExpression, ResolveExpressType.WhereSingle).GetResultString();
|
||||||
}
|
}
|
||||||
context.MappingTables = this.Context.MappingTables;
|
context.MappingTables = this.Context.MappingTables;
|
||||||
if (!SqlFuncExtendsion.TableInfos.Any(y => y.Type == typeof(T) && y.Code == uniqueCode))
|
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");
|
Check.Exception(true, "SetKeyValue error , entity & uniqueCode already exist");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void SetTable<T>(Expression<Func<T, object>> key, Expression<Func<T, object>> value)
|
public void SetTable<T>(Expression<Func<T, object>> key, Expression<Func<T, object>> value)
|
||||||
{
|
{
|
||||||
SetTable<T>(key,value, null,null);
|
SetTable<T>(key,value, null,null);
|
||||||
|
Loading…
Reference in New Issue
Block a user