mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-20 04:48:16 +08:00
- 调整内部参数化处理逻辑,为以后 Where 条件参数化做准备;
This commit is contained in:
@ -329,23 +329,23 @@ namespace FreeSql.Internal
|
||||
{ ExpressionType.Modulo, "%" },
|
||||
{ ExpressionType.Equal, "=" },
|
||||
};
|
||||
public string ExpressionWhereLambdaNoneForeignObject(List<SelectTableInfo> _tables, TableInfo table, List<SelectColumnInfo> _selectColumnMap, Expression exp, Func<Expression[], string> getSelectGroupingMapString)
|
||||
public string ExpressionWhereLambdaNoneForeignObject(List<SelectTableInfo> _tables, TableInfo table, List<SelectColumnInfo> _selectColumnMap, Expression exp, Func<Expression[], string> getSelectGroupingMapString, List<DbParameter> dbParams)
|
||||
{
|
||||
var sql = ExpressionLambdaToSql(exp, new ExpTSC { _tables = _tables, _selectColumnMap = _selectColumnMap, getSelectGroupingMapString = getSelectGroupingMapString, tbtype = SelectTableInfoType.From, isQuoteName = true, isDisableDiyParse = false, style = ExpressionStyle.Where, currentTable = table });
|
||||
var sql = ExpressionLambdaToSql(exp, new ExpTSC { _tables = _tables, _selectColumnMap = _selectColumnMap, getSelectGroupingMapString = getSelectGroupingMapString, tbtype = SelectTableInfoType.From, isQuoteName = true, isDisableDiyParse = false, style = ExpressionStyle.Where, currentTable = table, dbParams = dbParams });
|
||||
var isBool = exp.Type.NullableTypeOrThis() == typeof(bool);
|
||||
if (exp.NodeType == ExpressionType.MemberAccess && isBool && sql.Contains(" IS ") == false && sql.Contains(" = ") == false)
|
||||
return $"{sql} = {formatSql(true, null, null)}";
|
||||
return $"{sql} = {formatSql(true, null, null, null)}";
|
||||
if (isBool)
|
||||
return GetBoolString(sql);
|
||||
return sql;
|
||||
}
|
||||
|
||||
public string ExpressionWhereLambda(List<SelectTableInfo> _tables, Expression exp, Func<Expression[], string> getSelectGroupingMapString, List<LambdaExpression> whereCascadeExpression)
|
||||
public string ExpressionWhereLambda(List<SelectTableInfo> _tables, Expression exp, Func<Expression[], string> getSelectGroupingMapString, List<LambdaExpression> whereCascadeExpression, List<DbParameter> dbParams)
|
||||
{
|
||||
var sql = ExpressionLambdaToSql(exp, new ExpTSC { _tables = _tables, getSelectGroupingMapString = getSelectGroupingMapString, tbtype = SelectTableInfoType.From, isQuoteName = true, isDisableDiyParse = false, style = ExpressionStyle.Where, whereCascadeExpression = whereCascadeExpression });
|
||||
var sql = ExpressionLambdaToSql(exp, new ExpTSC { _tables = _tables, getSelectGroupingMapString = getSelectGroupingMapString, tbtype = SelectTableInfoType.From, isQuoteName = true, isDisableDiyParse = false, style = ExpressionStyle.Where, whereCascadeExpression = whereCascadeExpression, dbParams = dbParams });
|
||||
var isBool = exp.Type.NullableTypeOrThis() == typeof(bool);
|
||||
if (exp.NodeType == ExpressionType.MemberAccess && isBool && sql.Contains(" IS ") == false && sql.Contains(" = ") == false)
|
||||
return $"{sql} = {formatSql(true, null, null)}";
|
||||
return $"{sql} = {formatSql(true, null, null, null)}";
|
||||
if (isBool)
|
||||
return GetBoolString(sql);
|
||||
return sql;
|
||||
@ -357,7 +357,7 @@ namespace FreeSql.Internal
|
||||
var sql = ExpressionLambdaToSql(exp, new ExpTSC { _tables = _tables, getSelectGroupingMapString = getSelectGroupingMapString, tbtype = tbtype, isQuoteName = true, isDisableDiyParse = false, style = ExpressionStyle.Where, whereCascadeExpression = whereCascadeExpression });
|
||||
var isBool = exp.Type.NullableTypeOrThis() == typeof(bool);
|
||||
if (exp.NodeType == ExpressionType.MemberAccess && isBool && sql.Contains(" IS ") == false && sql.Contains(" = ") == false)
|
||||
sql = $"{sql} = {formatSql(true, null, null)}";
|
||||
sql = $"{sql} = {formatSql(true, null, null, null)}";
|
||||
if (isBool)
|
||||
sql = GetBoolString(sql);
|
||||
|
||||
@ -435,7 +435,7 @@ namespace FreeSql.Internal
|
||||
{
|
||||
var enumType = leftMapColumn.CsType.NullableTypeOrThis();
|
||||
if (enumType.IsEnum)
|
||||
right = formatSql(Enum.Parse(enumType, right.StartsWith("N'") ? right.Substring(1).Trim('\'') : right.Trim('\'')), leftMapColumn.Attribute.MapType, leftMapColumn);
|
||||
right = formatSql(Enum.Parse(enumType, right.StartsWith("N'") ? right.Substring(1).Trim('\'') : right.Trim('\'')), leftMapColumn.Attribute.MapType, leftMapColumn, tsc.dbParams);
|
||||
}
|
||||
if (leftMapColumn == null)
|
||||
{
|
||||
@ -449,7 +449,7 @@ namespace FreeSql.Internal
|
||||
{
|
||||
var enumType = rightMapColumn.CsType.NullableTypeOrThis();
|
||||
if (enumType.IsEnum)
|
||||
left = formatSql(Enum.Parse(enumType, left.StartsWith("N'") ? left.Substring(1).Trim('\'') : left.Trim('\'')), rightMapColumn.Attribute.MapType, rightMapColumn);
|
||||
left = formatSql(Enum.Parse(enumType, left.StartsWith("N'") ? left.Substring(1).Trim('\'') : left.Trim('\'')), rightMapColumn.Attribute.MapType, rightMapColumn, tsc.dbParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -457,8 +457,8 @@ namespace FreeSql.Internal
|
||||
{
|
||||
if (oper == "=")
|
||||
{
|
||||
var trueVal = formatSql(true, null, null);
|
||||
var falseVal = formatSql(false, null, null);
|
||||
var trueVal = formatSql(true, null, null, null);
|
||||
var falseVal = formatSql(false, null, null, null);
|
||||
if (left == trueVal) return right;
|
||||
else if (left == falseVal) return $"not({right})";
|
||||
else if (right == trueVal) return left;
|
||||
@ -466,8 +466,8 @@ namespace FreeSql.Internal
|
||||
}
|
||||
else if (oper == "<>")
|
||||
{
|
||||
var trueVal = formatSql(true, null, null);
|
||||
var falseVal = formatSql(false, null, null);
|
||||
var trueVal = formatSql(true, null, null, null);
|
||||
var falseVal = formatSql(false, null, null, null);
|
||||
if (left == trueVal) return $"not({right})";
|
||||
else if (left == falseVal) return right;
|
||||
else if (right == trueVal) return $"not({left})";
|
||||
@ -489,9 +489,9 @@ namespace FreeSql.Internal
|
||||
break;
|
||||
case "AND":
|
||||
case "OR":
|
||||
if (leftMapColumn != null) left = $"{left} = {formatSql(true, null, null)}";
|
||||
if (leftMapColumn != null) left = $"{left} = {formatSql(true, null, null, null)}";
|
||||
else left = GetBoolString(left);
|
||||
if (rightMapColumn != null) right = $"{right} = {formatSql(true, null, null)}";
|
||||
if (rightMapColumn != null) right = $"{right} = {formatSql(true, null, null, null)}";
|
||||
else right = GetBoolString(right);
|
||||
break;
|
||||
}
|
||||
@ -520,7 +520,7 @@ namespace FreeSql.Internal
|
||||
if (notBody.Contains(" IS NOT NULL")) return notBody.Replace(" IS NOT NULL", " IS NULL");
|
||||
if (notBody.Contains("=")) return notBody.Replace("=", "!=");
|
||||
if (notBody.Contains("!=")) return notBody.Replace("!=", "=");
|
||||
return $"{notBody} = {formatSql(false, null, null)}";
|
||||
return $"{notBody} = {formatSql(false, null, null, null)}";
|
||||
}
|
||||
return $"not({ExpressionLambdaToSql(notExp, tsc)})";
|
||||
case ExpressionType.Quote: return ExpressionLambdaToSql((exp as UnaryExpression)?.Operand, tsc);
|
||||
@ -532,7 +532,7 @@ namespace FreeSql.Internal
|
||||
return ExpressionLambdaToSql((exp as UnaryExpression)?.Operand, tsc);
|
||||
case ExpressionType.Negate:
|
||||
case ExpressionType.NegateChecked: return "-" + ExpressionLambdaToSql((exp as UnaryExpression)?.Operand, tsc);
|
||||
case ExpressionType.Constant: return formatSql((exp as ConstantExpression)?.Value, tsc.mapType, tsc.mapColumnTmp);
|
||||
case ExpressionType.Constant: return formatSql((exp as ConstantExpression)?.Value, tsc.mapType, tsc.mapColumnTmp, tsc.dbParams);
|
||||
case ExpressionType.Conditional:
|
||||
var condExp = exp as ConditionalExpression;
|
||||
return $"case when {ExpressionLambdaToSql(condExp.Test, tsc)} then {ExpressionLambdaToSql(condExp.IfTrue, tsc)} else {ExpressionLambdaToSql(condExp.IfFalse, tsc)} end";
|
||||
@ -890,7 +890,7 @@ namespace FreeSql.Internal
|
||||
//}
|
||||
other3Exp = ExpressionLambdaToSqlOther(exp3, tsc);
|
||||
if (string.IsNullOrEmpty(other3Exp) == false) return other3Exp;
|
||||
if (exp3.IsParameter() == false) return formatSql(Expression.Lambda(exp3).Compile().DynamicInvoke(), tsc.mapType, tsc.mapColumnTmp);
|
||||
if (exp3.IsParameter() == false) return formatSql(Expression.Lambda(exp3).Compile().DynamicInvoke(), tsc.mapType, tsc.mapColumnTmp, tsc.dbParams);
|
||||
throw new Exception($"未实现函数表达式 {exp3} 解析");
|
||||
case ExpressionType.Parameter:
|
||||
case ExpressionType.MemberAccess:
|
||||
@ -950,7 +950,7 @@ namespace FreeSql.Internal
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (expStack.First().NodeType != ExpressionType.Parameter) return formatSql(Expression.Lambda(exp).Compile().DynamicInvoke(), tsc.mapType, tsc.mapColumnTmp);
|
||||
if (expStack.First().NodeType != ExpressionType.Parameter) return formatSql(Expression.Lambda(exp).Compile().DynamicInvoke(), tsc.mapType, tsc.mapColumnTmp, tsc.dbParams);
|
||||
if (callExp != null) return ExpressionLambdaToSql(callExp, tsc);
|
||||
if (tsc.getSelectGroupingMapString != null && expStack.First().Type.FullName.StartsWith("FreeSql.ISelectGroupingAggregate`"))
|
||||
{
|
||||
@ -1161,7 +1161,7 @@ namespace FreeSql.Internal
|
||||
}
|
||||
if (dicExpressionOperator.TryGetValue(expBinary.NodeType, out var tryoper) == false)
|
||||
{
|
||||
if (exp.IsParameter() == false) return formatSql(Expression.Lambda(exp).Compile().DynamicInvoke(), tsc.mapType, tsc.mapColumnTmp);
|
||||
if (exp.IsParameter() == false) return formatSql(Expression.Lambda(exp).Compile().DynamicInvoke(), tsc.mapType, tsc.mapColumnTmp, tsc.dbParams);
|
||||
return "";
|
||||
}
|
||||
return ExpressionBinary(tryoper, expBinary.Left, expBinary.Right, tsc);
|
||||
@ -1195,6 +1195,7 @@ namespace FreeSql.Internal
|
||||
public ColumnInfo mapColumnTmp { get; set; }
|
||||
public TableInfo currentTable { get; set; }
|
||||
public List<LambdaExpression> whereCascadeExpression { get; set; }
|
||||
public List<DbParameter> dbParams { get; set; }
|
||||
public string alias001 { get; set; } //单表字段的表别名
|
||||
|
||||
public ExpTSC SetMapColumnTmp(ColumnInfo col)
|
||||
@ -1229,8 +1230,12 @@ namespace FreeSql.Internal
|
||||
isQuoteName = this.isQuoteName,
|
||||
isDisableDiyParse = this.isDisableDiyParse,
|
||||
style = this.style,
|
||||
//mapType = this.mapType,
|
||||
//mapTypeTmp = this.mapTypeTmp,
|
||||
//mapColumnTmp = this.mapColumnTmp,
|
||||
currentTable = this.currentTable,
|
||||
whereCascadeExpression = this.whereCascadeExpression,
|
||||
dbParams = this.dbParams,
|
||||
alias001 = this.alias001
|
||||
};
|
||||
}
|
||||
@ -1245,8 +1250,12 @@ namespace FreeSql.Internal
|
||||
isQuoteName = this.isQuoteName,
|
||||
isDisableDiyParse = true,
|
||||
style = this.style,
|
||||
mapType = this.mapType,
|
||||
mapTypeTmp = this.mapTypeTmp,
|
||||
mapColumnTmp = this.mapColumnTmp,
|
||||
currentTable = this.currentTable,
|
||||
whereCascadeExpression = this.whereCascadeExpression,
|
||||
dbParams = this.dbParams,
|
||||
alias001 = this.alias001
|
||||
};
|
||||
}
|
||||
@ -1309,6 +1318,17 @@ namespace FreeSql.Internal
|
||||
}
|
||||
}
|
||||
|
||||
public string formatSql(object obj, Type mapType, ColumnInfo mapColumn) => string.Concat(_ado.AddslashesProcessParam(obj, mapType, mapColumn));
|
||||
public string formatSql(object obj, Type mapType, ColumnInfo mapColumn, List<DbParameter> dbParams)
|
||||
{
|
||||
//参数化设置,日后优化
|
||||
//if (dbParams != null && mapColumn != null)
|
||||
//{
|
||||
// var paramName = $"exp_{dbParams.Count}";
|
||||
// var parm = _common.AppendParamter(dbParams, paramName, mapColumn, mapType ?? mapColumn.Attribute.MapType, mapType == null ? obj : Utils.GetDataReaderValue(mapType, obj));
|
||||
// _common.SetParameterSize(parm, mapColumn.Attribute.DbType, mapColumn);
|
||||
// return _common.QuoteParamterName(paramName);
|
||||
//}
|
||||
return string.Concat(_ado.AddslashesProcessParam(obj, mapType, mapColumn));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
protected int _whereTimes = 0;
|
||||
protected List<GlobalFilter.Item> _whereGlobalFilter;
|
||||
protected List<DbParameter> _params = new List<DbParameter>();
|
||||
protected bool _noneParameter;
|
||||
protected DbTransaction _transaction;
|
||||
protected DbConnection _connection;
|
||||
|
||||
@ -31,6 +32,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
_commonUtils = commonUtils;
|
||||
_commonExpression = commonExpression;
|
||||
_table = _commonUtils.GetTableByEntity(typeof(T1));
|
||||
_noneParameter = _orm.CodeFirst.IsNoneCommandParameter;
|
||||
this.Where(_commonUtils.WhereObject(_table, "", dywhere));
|
||||
if (_orm.CodeFirst.IsAutoSyncStructure && typeof(T1) != typeof(object)) _orm.CodeFirst.SyncStructure<T1>();
|
||||
_whereGlobalFilter = _orm.GlobalFilter.GetFilters();
|
||||
@ -85,7 +87,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
}
|
||||
public abstract List<T1> ExecuteDeleted();
|
||||
|
||||
public IDelete<T1> Where(Expression<Func<T1, bool>> exp) => this.Where(_commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, null, exp?.Body, null));
|
||||
public IDelete<T1> Where(Expression<Func<T1, bool>> exp) => this.Where(_commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, null, exp?.Body, null, _noneParameter ? _params : null));
|
||||
public IDelete<T1> Where(string sql, object parms = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sql)) return this;
|
||||
|
@ -451,7 +451,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
else
|
||||
{
|
||||
sb.Append(_commonUtils.QuoteWriteParamter(col.Attribute.MapType, _commonUtils.QuoteParamterName($"{col.CsName}_{didx}")));
|
||||
_params[didx * colidx + colidx2] = _commonUtils.AppendParamter(null, $"{col.CsName}_{didx}", col.Attribute.MapType, val);
|
||||
_params[didx * colidx + colidx2] = _commonUtils.AppendParamter(null, $"{col.CsName}_{didx}", col, col.Attribute.MapType, val);
|
||||
}
|
||||
++colidx2;
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
protected Action<object> _trackToList;
|
||||
protected List<Action<object>> _includeToList = new List<Action<object>>();
|
||||
protected bool _distinct;
|
||||
protected bool _noneParameter;
|
||||
protected Expression _selectExpression;
|
||||
protected List<LambdaExpression> _whereCascadeExpression = new List<LambdaExpression>();
|
||||
protected List<GlobalFilter.Item> _whereGlobalFilter;
|
||||
@ -105,6 +106,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
toType.GetField("_trackToList", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(to, from._trackToList);
|
||||
toType.GetField("_includeToList", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(to, from._includeToList);
|
||||
toType.GetField("_distinct", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(to, from._distinct);
|
||||
toType.GetField("_noneParameter", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(to, from._noneParameter);
|
||||
toType.GetField("_selectExpression", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(to, from._selectExpression);
|
||||
toType.GetField("_whereCascadeExpression", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(to, from._whereCascadeExpression);
|
||||
toType.GetField("_whereGlobalFilter", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(to, from._whereGlobalFilter);
|
||||
@ -116,6 +118,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
_commonUtils = commonUtils;
|
||||
_commonExpression = commonExpression;
|
||||
_tables.Add(new SelectTableInfo { Table = _commonUtils.GetTableByEntity(typeof(T1)), Alias = "a", On = null, Type = SelectTableInfoType.From });
|
||||
_noneParameter = _orm.CodeFirst.IsNoneCommandParameter;
|
||||
this.Where(_commonUtils.WhereObject(_tables.First().Table, "a.", dywhere));
|
||||
if (_orm.CodeFirst.IsAutoSyncStructure && typeof(T1) != typeof(object)) _orm.CodeFirst.SyncStructure<T1>();
|
||||
}
|
||||
@ -1051,7 +1054,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
return this.ToListMapReader<TReturn>((map, field.Length > 0 ? field.Remove(0, 2).ToString() : null)).FirstOrDefault();
|
||||
}
|
||||
|
||||
protected TSelect InternalWhere(Expression exp) => exp == null ? this as TSelect : this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp, null, _whereCascadeExpression));
|
||||
protected TSelect InternalWhere(Expression exp) => exp == null ? this as TSelect : this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp, null, _whereCascadeExpression, _noneParameter ? _params : null));
|
||||
#endregion
|
||||
|
||||
#if net40
|
||||
|
@ -153,21 +153,21 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null));
|
||||
}
|
||||
|
||||
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression)) : this;
|
||||
return condition ? this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null)) : this;
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> exp)
|
||||
{
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression)).Any();
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null)).Any();
|
||||
}
|
||||
|
||||
#if net40
|
||||
@ -226,7 +226,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression)).AnyAsync();
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null)).AnyAsync();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (tb == null) throw new Exception("Include 参数类型错误");
|
||||
|
||||
_isIncluded = true;
|
||||
_commonExpression.ExpressionWhereLambda(_tables, Expression.MakeMemberAccess(expBody, tb.Properties[tb.ColumnsByCs.First().Value.CsName]), null, null);
|
||||
_commonExpression.ExpressionWhereLambda(_tables, Expression.MakeMemberAccess(expBody, tb.Properties[tb.ColumnsByCs.First().Value.CsName]), null, null, null);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -422,7 +422,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (tbNav == null) throw new Exception($"类型 {typeof(TNavigate).FullName} 错误,不能使用 IncludeMany");
|
||||
|
||||
if (collMem.Expression.NodeType != ExpressionType.Parameter)
|
||||
_commonExpression.ExpressionWhereLambda(_tables, Expression.MakeMemberAccess(collMem.Expression, tb.Properties[tb.ColumnsByCs.First().Value.CsName]), null, null);
|
||||
_commonExpression.ExpressionWhereLambda(_tables, Expression.MakeMemberAccess(collMem.Expression, tb.Properties[tb.ColumnsByCs.First().Value.CsName]), null, null, null);
|
||||
|
||||
TableRef tbref = null;
|
||||
var tbrefOneToManyColumns = new List<List<MemberExpression>>(); //临时 OneToMany 三个表关联,第三个表需要前两个表确定
|
||||
|
@ -130,21 +130,21 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null));
|
||||
}
|
||||
|
||||
ISelect<T1, T2> ISelect<T1, T2>.WhereIf(bool condition, Expression<Func<T1, T2, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2>.Any(Expression<Func<T1, T2, bool>> exp)
|
||||
{
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression)).Any();
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null)).Any();
|
||||
}
|
||||
|
||||
#if net40
|
||||
@ -203,7 +203,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression)).AnyAsync();
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null)).AnyAsync();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -133,21 +133,21 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null));
|
||||
}
|
||||
|
||||
ISelect<T1, T2, T3> ISelect<T1, T2, T3>.WhereIf(bool condition, Expression<Func<T1, T2, T3, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3>.Any(Expression<Func<T1, T2, T3, bool>> exp)
|
||||
{
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression)).Any();
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null)).Any();
|
||||
}
|
||||
|
||||
#if net40
|
||||
@ -206,7 +206,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression)).AnyAsync();
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null)).AnyAsync();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -136,21 +136,21 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null));
|
||||
}
|
||||
|
||||
ISelect<T1, T2, T3, T4> ISelect<T1, T2, T3, T4>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3, T4>.Any(Expression<Func<T1, T2, T3, T4, bool>> exp)
|
||||
{
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression)).Any();
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null)).Any();
|
||||
}
|
||||
|
||||
#if net40
|
||||
@ -209,7 +209,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression)).AnyAsync();
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null)).AnyAsync();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -139,21 +139,21 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null));
|
||||
}
|
||||
|
||||
ISelect<T1, T2, T3, T4, T5> ISelect<T1, T2, T3, T4, T5>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3, T4, T5>.Any(Expression<Func<T1, T2, T3, T4, T5, bool>> exp)
|
||||
{
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression)).Any();
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null)).Any();
|
||||
}
|
||||
|
||||
#if net40
|
||||
@ -212,7 +212,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression)).AnyAsync();
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null)).AnyAsync();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -142,21 +142,21 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null));
|
||||
}
|
||||
|
||||
ISelect<T1, T2, T3, T4, T5, T6> ISelect<T1, T2, T3, T4, T5, T6>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3, T4, T5, T6>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, bool>> exp)
|
||||
{
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression)).Any();
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null)).Any();
|
||||
}
|
||||
|
||||
#if net40
|
||||
@ -215,7 +215,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression)).AnyAsync();
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null)).AnyAsync();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -145,21 +145,21 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null));
|
||||
}
|
||||
|
||||
ISelect<T1, T2, T3, T4, T5, T6, T7> ISelect<T1, T2, T3, T4, T5, T6, T7>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3, T4, T5, T6, T7>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, bool>> exp)
|
||||
{
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression)).Any();
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null)).Any();
|
||||
}
|
||||
|
||||
#if net40
|
||||
@ -218,7 +218,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression)).AnyAsync();
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null)).AnyAsync();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -149,21 +149,21 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null));
|
||||
}
|
||||
|
||||
ISelect<T1, T2, T3, T4, T5, T6, T7, T8> ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3, T4, T5, T6, T7, T8>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, bool>> exp)
|
||||
{
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression)).Any();
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null)).Any();
|
||||
}
|
||||
|
||||
#if net40
|
||||
@ -222,7 +222,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression)).AnyAsync();
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null)).AnyAsync();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -147,20 +147,20 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.Where(null);
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null));
|
||||
}
|
||||
ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.WhereIf(bool condition, Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, bool>> exp)
|
||||
{
|
||||
if (condition == false || exp == null) return this;
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression));
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null));
|
||||
}
|
||||
|
||||
bool ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.Any(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, bool>> exp)
|
||||
{
|
||||
if (exp == null) return this.Any();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression)).Any();
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null)).Any();
|
||||
}
|
||||
|
||||
#if net40
|
||||
@ -169,7 +169,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
{
|
||||
if (exp == null) return this.AnyAsync();
|
||||
for (var a = 0; a < exp.Parameters.Count; a++) _tables[a].Parameter = exp.Parameters[a];
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression)).AnyAsync();
|
||||
return this.Where(_commonExpression.ExpressionWhereLambda(_tables, exp?.Body, null, _whereCascadeExpression, _noneParameter ? _params : null)).AnyAsync();
|
||||
}
|
||||
|
||||
Task<DataTable> ISelect<T1, T2, T3, T4, T5, T6, T7, T8, T9>.ToDataTableAsync<TReturn>(Expression<Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TReturn>> select)
|
||||
|
@ -84,7 +84,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
|
||||
public ISelectGrouping<TKey, TValue> Having(Expression<Func<ISelectGroupingAggregate<TKey, TValue>, bool>> exp)
|
||||
{
|
||||
var sql = _comonExp.ExpressionWhereLambda(null, exp, getSelectGroupingMapString, null);
|
||||
var sql = _comonExp.ExpressionWhereLambda(null, exp, getSelectGroupingMapString, null, null);
|
||||
var method = _select.GetType().GetMethod("Having", new[] { typeof(string), typeof(object) });
|
||||
method.Invoke(_select, new object[] { sql, null });
|
||||
return this;
|
||||
@ -92,7 +92,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
|
||||
public ISelectGrouping<TKey, TValue> OrderBy<TMember>(Expression<Func<ISelectGroupingAggregate<TKey, TValue>, TMember>> column)
|
||||
{
|
||||
var sql = _comonExp.ExpressionWhereLambda(null, column, getSelectGroupingMapString, null);
|
||||
var sql = _comonExp.ExpressionWhereLambda(null, column, getSelectGroupingMapString, null, null);
|
||||
var method = _select.GetType().GetMethod("OrderBy", new[] { typeof(string), typeof(object) });
|
||||
method.Invoke(_select, new object[] { sql, null });
|
||||
return this;
|
||||
@ -100,7 +100,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
|
||||
public ISelectGrouping<TKey, TValue> OrderByDescending<TMember>(Expression<Func<ISelectGroupingAggregate<TKey, TValue>, TMember>> column)
|
||||
{
|
||||
var sql = _comonExp.ExpressionWhereLambda(null, column, getSelectGroupingMapString, null);
|
||||
var sql = _comonExp.ExpressionWhereLambda(null, column, getSelectGroupingMapString, null, null);
|
||||
var method = _select.GetType().GetMethod("OrderBy", new[] { typeof(string), typeof(object) });
|
||||
method.Invoke(_select, new object[] { $"{sql} DESC", null });
|
||||
return this;
|
||||
|
@ -353,7 +353,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
else
|
||||
{
|
||||
_set.Append(_commonUtils.QuoteWriteParamter(col.Column.Attribute.MapType, $"{_commonUtils.QuoteParamterName("p_")}{_params.Count}"));
|
||||
_commonUtils.AppendParamter(_params, null, col.Column.Attribute.MapType, paramVal);
|
||||
_commonUtils.AppendParamter(_params, null, col.Column, col.Column.Attribute.MapType, paramVal);
|
||||
}
|
||||
//foreach (var t in _source) Utils.FillPropertyValue(t, tryf.CsName, value);
|
||||
return this;
|
||||
@ -365,7 +365,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
switch (nodeType)
|
||||
{
|
||||
case ExpressionType.Equal:
|
||||
_set.Append(", ").Append(_commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, null, exp, null));
|
||||
_set.Append(", ").Append(_commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, null, exp, null, null));
|
||||
return this;
|
||||
case ExpressionType.MemberInit:
|
||||
var initExp = body as MemberInitExpression;
|
||||
@ -401,7 +401,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
if (body is BinaryExpression == false &&
|
||||
nodeType != ExpressionType.Call) return this;
|
||||
var cols = new List<SelectColumnInfo>();
|
||||
var expt = _commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, cols, exp, null);
|
||||
var expt = _commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, cols, exp, null, null);
|
||||
if (cols.Any() == false) return this;
|
||||
foreach (var col in cols)
|
||||
{
|
||||
@ -424,7 +424,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
return this;
|
||||
}
|
||||
|
||||
public IUpdate<T1> Where(Expression<Func<T1, bool>> expression) => this.Where(_commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, null, expression?.Body, null));
|
||||
public IUpdate<T1> Where(Expression<Func<T1, bool>> expression) => this.Where(_commonExpression.ExpressionWhereLambdaNoneForeignObject(null, _table, null, expression?.Body, null, _noneParameter ? _params : null));
|
||||
public IUpdate<T1> Where(string sql, object parms = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sql)) return this;
|
||||
@ -564,7 +564,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
else
|
||||
{
|
||||
sb.Append(_commonUtils.QuoteWriteParamter(col.Attribute.MapType, _commonUtils.QuoteParamterName($"p_{_paramsSource.Count}")));
|
||||
_commonUtils.AppendParamter(_paramsSource, null, col.Attribute.MapType, val);
|
||||
_commonUtils.AppendParamter(_paramsSource, null, col, col.Attribute.MapType, val);
|
||||
}
|
||||
++colidx;
|
||||
}
|
||||
@ -603,7 +603,7 @@ namespace FreeSql.Internal.CommonProvider
|
||||
else
|
||||
{
|
||||
cwsb.Append(_commonUtils.QuoteWriteParamter(col.Attribute.MapType, _commonUtils.QuoteParamterName($"p_{_paramsSource.Count}")));
|
||||
_commonUtils.AppendParamter(_paramsSource, null, col.Attribute.MapType, val);
|
||||
_commonUtils.AppendParamter(_paramsSource, null, col, col.Attribute.MapType, val);
|
||||
}
|
||||
if (val == null || val == DBNull.Value) nulls++;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using System.Xml.XPath;
|
||||
@ -23,7 +24,7 @@ namespace FreeSql.Internal
|
||||
{
|
||||
|
||||
public abstract string GetNoneParamaterSqlValue(List<DbParameter> specialParams, Type type, object value);
|
||||
public abstract DbParameter AppendParamter(List<DbParameter> _params, string parameterName, Type type, object value);
|
||||
public abstract DbParameter AppendParamter(List<DbParameter> _params, string parameterName, ColumnInfo col, Type type, object value);
|
||||
public abstract DbParameter[] GetDbParamtersByObject(string sql, object obj);
|
||||
public abstract string FormatSql(string sql, params object[] args);
|
||||
public abstract string QuoteSqlName(string name);
|
||||
@ -47,6 +48,25 @@ namespace FreeSql.Internal
|
||||
_orm = orm;
|
||||
}
|
||||
|
||||
static Regex _regexSize = new Regex(@"\(([^\)]+)\)", RegexOptions.Compiled);
|
||||
internal void SetParameterSize(DbParameter parm, string dbtypeFull, ColumnInfo col)
|
||||
{
|
||||
if (col == null) return;
|
||||
if (string.IsNullOrEmpty(dbtypeFull)) return;
|
||||
var m = _regexSize.Match(dbtypeFull);
|
||||
if (m.Success == false) return;
|
||||
var sizeStr = m.Groups[1].Value.Trim();
|
||||
if (string.Compare(sizeStr, "max", true) == 0)
|
||||
{
|
||||
parm.Size = -1;
|
||||
return;
|
||||
}
|
||||
var sizeArr = sizeStr.Split(',');
|
||||
if (int.TryParse(sizeArr[0], out var size) == false) return;
|
||||
if (sizeArr.Length > 1 && int.TryParse(sizeArr[1], out var size2)) size += size2;
|
||||
parm.Size = size;
|
||||
}
|
||||
|
||||
ConcurrentDictionary<Type, TableAttribute> dicConfigEntity = new ConcurrentDictionary<Type, TableAttribute>();
|
||||
public ICodeFirst ConfigEntity<T>(Action<TableFluent<T>> entity)
|
||||
{
|
||||
|
Reference in New Issue
Block a user