mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-12-26 14:15:50 +08:00
rename
This commit is contained in:
@@ -27,12 +27,12 @@ namespace OrmTest
|
||||
private static void ConfiQuery()
|
||||
{
|
||||
var db = GetInstance();
|
||||
db.SqlConfigTable.SetKeyValue<Order>(it=>it.Id ,it=>it.Name,"01",it=>it.Id>1);
|
||||
db.SqlConfigTable.SetKeyValue<Order>(it => it.Id, it => it.Name, "02", it => it.Id > 2);
|
||||
db.SqlConfigTable.SetKeyValue<Order>(it => it.Id, it => it.Name,null);
|
||||
db.ConfigQuery.SetTable<Order>(it=>it.Id ,it=>it.Name,"01",it=>it.Id>1);
|
||||
db.ConfigQuery.SetTable<Order>(it => it.Id, it => it.Name, "02", it => it.Id > 2);
|
||||
db.ConfigQuery.SetTable<Order>(it => it.Id, it => it.Name,null);
|
||||
var list = db.Queryable<OrderItem>().Select(it => new OrderItem
|
||||
{
|
||||
ItemId = SqlFunc.GetSelfAndAutoFill(it.ItemId),
|
||||
ItemId = it.ItemId.SelectAll(),
|
||||
OrderName = it.OrderId.GetConfigValue<Order>("01")
|
||||
}).ToList();
|
||||
var list2 = db.Queryable<OrderItem>().Select(it => new OrderItem
|
||||
|
||||
@@ -31,12 +31,12 @@ namespace SqlSugar
|
||||
public MappingColumnList MappingColumns { get; set; }
|
||||
public IgnoreColumnList IgnoreColumns { get; set; }
|
||||
public IgnoreColumnList IgnoreInsertColumns { get; set; }
|
||||
public SqlConfigTable SqlConfigTable {
|
||||
public ConfigQuery ConfigQuery {
|
||||
get
|
||||
{
|
||||
if (_SqlConfigTable==null)
|
||||
{
|
||||
_SqlConfigTable = new SqlConfigTable() { Context = this.Context };
|
||||
_SqlConfigTable = new ConfigQuery() { Context = this.Context };
|
||||
}
|
||||
return _SqlConfigTable;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ namespace SqlSugar
|
||||
protected IContextMethods _RewritableMethods;
|
||||
protected IDbMaintenance _DbMaintenance;
|
||||
protected QueryFilterProvider _QueryFilterProvider;
|
||||
protected SqlConfigTable _SqlConfigTable;
|
||||
protected ConfigQuery _SqlConfigTable;
|
||||
//protected SimpleClient _SimpleClient;
|
||||
protected IAdo ContextAdo
|
||||
{
|
||||
|
||||
@@ -6,16 +6,16 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
namespace SqlSugar
|
||||
{
|
||||
public class SqlConfigTable
|
||||
public class ConfigQuery
|
||||
{
|
||||
public SqlSugarProvider Context { get; set; }
|
||||
public void SetKeyValue<T>(Expression<Func<T, object>> keyExpression, Expression<Func<T, object>> valueExpression, 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)
|
||||
{
|
||||
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 ValueValue = query.GetExpressionValue(valueExpression, ResolveExpressType.FieldSingle).GetString();
|
||||
var ValueValue = query.GetExpressionValue(valueTextExpression, ResolveExpressType.FieldSingle).GetString();
|
||||
string where = null;
|
||||
if (whereExpression != null)
|
||||
{
|
||||
@@ -40,9 +40,9 @@ namespace SqlSugar
|
||||
Check.Exception(true, "SetKeyValue error , entity & uniqueCode already exist");
|
||||
}
|
||||
}
|
||||
public void SetKeyValue<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)
|
||||
{
|
||||
SetKeyValue<T>(key,value, null,null);
|
||||
SetTable<T>(key,value, null,null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,5 +18,10 @@ namespace SqlSugar
|
||||
{
|
||||
throw new NotSupportedException("Can only be used in expressions");
|
||||
}
|
||||
|
||||
public static FieldType SelectAll<FieldType>(this FieldType field)
|
||||
{
|
||||
throw new NotSupportedException("Can only be used in expressions");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -277,7 +277,7 @@ namespace SqlSugar
|
||||
}
|
||||
protected void Select(ExpressionParameter parameter, bool? isLeft, string name, IEnumerable<Expression> args, MethodCallExpressionModel model, List<MethodCallExpressionArgs> appendArgs = null)
|
||||
{
|
||||
if (name == "GetSelfAndAutoFill")
|
||||
if (name.IsIn("GetSelfAndAutoFill","SelectAll"))
|
||||
{
|
||||
var memberValue = (args.First() as MemberExpression).Expression.ToString();
|
||||
model.Args.Add(new MethodCallExpressionArgs() { MemberValue = memberValue, IsMember = true, MemberName = memberValue });
|
||||
@@ -722,6 +722,7 @@ namespace SqlSugar
|
||||
return this.Context.DbMehtods.IsNull(model);
|
||||
case "MergeString":
|
||||
return this.Context.DbMehtods.MergeString(model.Args.Select(it => it.MemberName.ObjToString()).ToArray());
|
||||
case "SelectAll":
|
||||
case "GetSelfAndAutoFill":
|
||||
this.Context.Parameters.RemoveAll(it => it.ParameterName == model.Args[0].MemberName.ObjToString());
|
||||
return this.Context.DbMehtods.GetSelfAndAutoFill(model.Args[0].MemberValue.ObjToString(), this.Context.IsSingle);
|
||||
@@ -761,6 +762,10 @@ namespace SqlSugar
|
||||
}
|
||||
private bool CheckMethod(MethodCallExpression expression)
|
||||
{
|
||||
if (expression.Method.Name=="SelectAll")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (IsExtMethod(expression.Method.Name))
|
||||
return true;
|
||||
if (IsParseMethod(expression))
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace SqlSugar
|
||||
IgnoreColumnList IgnoreColumns { get; set; }
|
||||
IgnoreColumnList IgnoreInsertColumns { get; set; }
|
||||
Dictionary<string, object> TempItems { get; set; }
|
||||
SqlConfigTable SqlConfigTable { get; set; }
|
||||
ConfigQuery ConfigQuery { get; set; }
|
||||
|
||||
bool IsSystemTablesConfig { get; }
|
||||
Guid ContextID { get; set; }
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace SqlSugar
|
||||
public bool IsSystemTablesConfig => this.Context.IsSystemTablesConfig;
|
||||
public ConnectionConfig CurrentConnectionConfig { get { return _CurrentConnectionConfig; } set { _CurrentConnectionConfig = value; } }
|
||||
public Guid ContextID { get { return this.Context.ContextID; } set { this.Context.ContextID = value; } }
|
||||
public SqlConfigTable SqlConfigTable { get { return this.Context.SqlConfigTable; } set { this.Context.SqlConfigTable = value; } }
|
||||
public ConfigQuery ConfigQuery { get { return this.Context.ConfigQuery; } set { this.Context.ConfigQuery = value; } }
|
||||
|
||||
public MappingTableList MappingTables { get { return _MappingTables; } set { _MappingTables = value; } }
|
||||
public MappingColumnList MappingColumns { get { return _MappingColumns; } set { _MappingColumns = value; } }
|
||||
|
||||
Reference in New Issue
Block a user