Add OrderByIF

This commit is contained in:
sunkaixuan
2017-09-22 17:09:56 +08:00
parent 71f69edeea
commit f3009416dd
2 changed files with 58 additions and 12 deletions

View File

@@ -277,6 +277,21 @@ namespace SqlSugar
return this;
}
public virtual ISugarQueryable<T> OrderByIF(bool isOrderBy, string orderFileds)
{
if (isOrderBy)
return this.OrderBy(orderFileds);
else
return this;
}
public virtual ISugarQueryable<T> OrderByIF(bool isOrderBy, Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
{
if (isOrderBy)
return this.OrderBy(expression, type);
else
return this;
}
public virtual ISugarQueryable<T> GroupBy(string groupFileds)
{
var croupByValue = QueryBuilder.GroupByValue;
@@ -1134,6 +1149,11 @@ namespace SqlSugar
#endregion
#region Order
public new ISugarQueryable<T, T2> OrderBy(string orderFileds)
{
base.OrderBy(orderFileds);
return this;
}
public ISugarQueryable<T, T2> OrderBy(Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc)
{
_OrderBy(expression, type);
@@ -1145,6 +1165,24 @@ namespace SqlSugar
_OrderBy(expression, type);
return this;
}
public new ISugarQueryable<T, T2> OrderByIF(bool isOrderBy, string orderFileds)
{
if (isOrderBy)
base.OrderBy(orderFileds);
return this;
}
public new ISugarQueryable<T, T2> OrderByIF(bool isOrderBy, Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc)
{
if (isOrderBy)
_OrderBy(expression,type);
return this;
}
public ISugarQueryable<T, T2> OrderByIF(bool isOrderBy, Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc)
{
if (isOrderBy)
_OrderBy(expression, type);
return this;
}
#endregion
#region GroupBy

View File

@@ -44,6 +44,10 @@ namespace SqlSugar
ISugarQueryable<T> OrderBy(string orderFileds);
ISugarQueryable<T> OrderBy(Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc);
ISugarQueryable<T> OrderByIF(bool isOrderBy,string orderFileds);
ISugarQueryable<T> OrderByIF(bool isOrderBy, Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc);
ISugarQueryable<T> GroupBy(Expression<Func<T, object>> expression);
ISugarQueryable<T> GroupBy(string groupFileds);
@@ -137,8 +141,12 @@ namespace SqlSugar
#endregion
#region OrderBy
new ISugarQueryable<T,T2> OrderBy(string orderFileds);
new ISugarQueryable<T, T2> OrderBy(Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc);
ISugarQueryable<T, T2> OrderBy(Expression<Func<T, T2, object>> expression, OrderByType type = OrderByType.Asc);
new ISugarQueryable<T,T2> OrderByIF(bool isOrderBy, string orderFileds);
new ISugarQueryable<T, T2> OrderByIF(bool isOrderBy, Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc);
ISugarQueryable<T,T2> OrderByIF(bool isOrderBy, Expression<Func<T,T2, object>> expression, OrderByType type = OrderByType.Asc);
#endregion
#region GroupBy