Browse Source

-

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
24a237aedc
  1. 14
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs
  2. 1
      Src/Asp.Net/SqlSugar/Interface/IQueryable.cs

14
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs

@ -258,6 +258,20 @@ namespace SqlSugar
}
return In(expression, inValues.ToArray());
}
public virtual ISugarQueryable<T> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression) {
var sqlObj=childQueryExpression.ToSql();
if (sqlObj.Value.IsValuable()) {
this.QueryBuilder.Parameters.AddRange(sqlObj.Value);
}
var isSingle = QueryBuilder.IsSingle();
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
var fieldName = lamResult.GetResultString();
var whereSql = string.Format(this.QueryBuilder.InTemplate, fieldName, sqlObj.Key);
this.QueryBuilder.WhereInfos.Add(SqlBuilder.AppendWhereOrAnd(this.QueryBuilder.WhereInfos.IsNullOrEmpty(),whereSql));
return this;
}
public virtual ISugarQueryable<T> OrderBy(string orderFileds)
{
var orderByValue = QueryBuilder.OrderByValue;

1
Src/Asp.Net/SqlSugar/Interface/IQueryable.cs

@ -36,6 +36,7 @@ namespace SqlSugar
ISugarQueryable<T> In<TParamter>(List<TParamter> pkValues);
ISugarQueryable<T> In<FieldType>(string InFieldName, List<FieldType> inValues);
ISugarQueryable<T> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues);
ISugarQueryable<T> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression);
ISugarQueryable<T> OrderBy(string orderFileds);
ISugarQueryable<T> OrderBy(Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc);

Loading…
Cancel
Save