mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-20 02:29:39 +08:00
Add queryable.OrderByPropertyName
This commit is contained in:
@@ -1044,6 +1044,26 @@ namespace SqlSugar
|
|||||||
this.QueryBuilder.SampleBy = sql;
|
this.QueryBuilder.SampleBy = sql;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public ISugarQueryable<T> OrderByPropertyName(string orderPropertyName, OrderByType? orderByType = null)
|
||||||
|
{
|
||||||
|
if (orderPropertyName != null)
|
||||||
|
{
|
||||||
|
if (this.Context.EntityMaintenance.GetEntityInfoWithAttr(typeof(T)).Columns.Any(it =>
|
||||||
|
it.DbColumnName?.EqualCase(orderPropertyName)==true
|
||||||
|
|| it.PropertyName?.EqualCase(orderPropertyName)==true))
|
||||||
|
{
|
||||||
|
var name = this.Context.EntityMaintenance.GetEntityInfoWithAttr(typeof(T)).Columns.FirstOrDefault(it =>
|
||||||
|
it.DbColumnName?.EqualCase(orderPropertyName) == true
|
||||||
|
|| it.PropertyName?.EqualCase(orderPropertyName) == true)?.DbColumnName;
|
||||||
|
return this.OrderBy(this.SqlBuilder.GetTranslationColumnName( name) + " "+orderByType);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Check.ExceptionEasy($"OrderByPropertyName error.{orderPropertyName} does not exist in the entity class", $"OrderByPropertyName出错实体类中不存在{orderPropertyName}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
public virtual ISugarQueryable<T> OrderBy(string orderFileds)
|
public virtual ISugarQueryable<T> OrderBy(string orderFileds)
|
||||||
{
|
{
|
||||||
orderFileds = orderFileds.ToCheckField();
|
orderFileds = orderFileds.ToCheckField();
|
||||||
|
@@ -105,6 +105,7 @@ namespace SqlSugar
|
|||||||
ISugarQueryable<T> InIF<FieldType>(bool isWhere,Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression);
|
ISugarQueryable<T> InIF<FieldType>(bool isWhere,Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression);
|
||||||
|
|
||||||
ISugarQueryable<T> OrderBy(string orderFileds);
|
ISugarQueryable<T> OrderBy(string orderFileds);
|
||||||
|
ISugarQueryable<T> OrderByPropertyName(string orderPropertyName,OrderByType? orderByType=null);
|
||||||
ISugarQueryable<T> OrderBy(Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc);
|
ISugarQueryable<T> OrderBy(Expression<Func<T, object>> expression, OrderByType type = OrderByType.Asc);
|
||||||
ISugarQueryable<T> OrderByDescending(Expression<Func<T, object>> expression);
|
ISugarQueryable<T> OrderByDescending(Expression<Func<T, object>> expression);
|
||||||
ISugarQueryable<T> OrderByIF(bool isOrderBy, string orderFileds);
|
ISugarQueryable<T> OrderByIF(bool isOrderBy, string orderFileds);
|
||||||
|
Reference in New Issue
Block a user