mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-20 02:29:39 +08:00
-
This commit is contained in:
@@ -47,6 +47,9 @@ namespace OrmTest.Demo
|
||||
|
||||
var getAll9 = db.Queryable<Student>().Where(it => SqlFunc.Subqueryable<School>().Where(s => s.Id == it.Id).Count()==1).ToList();
|
||||
|
||||
var getAll10 = db.Queryable<Student>().Where(it => SqlFunc.Subqueryable<School>().Where(s => s.Id == it.Id).OrderBy(s=>s.Id).Select(s=>s.Id) == 1).ToList();
|
||||
var getAll14 = db.Queryable<Student>().Where(it => SqlFunc.Subqueryable<School>().Where(s => s.Id == it.Id).OrderByDesc(s => s.Id).Select(s => s.Id) == 1).ToList();
|
||||
|
||||
var getAll8= db.Queryable<Student>().Where(it => SqlFunc.Subqueryable<School>().Where(s => s.Id == it.Id).Where(s=>s.Name==it.Name).NotAny()).ToList();
|
||||
|
||||
var getAll1 = db.Queryable<Student>().Where(it => it.Id == SqlFunc.Subqueryable<School>().Where(s => s.Id == it.Id).Select(s => s.Id)).ToList();
|
||||
|
@@ -41,4 +41,39 @@ namespace SqlSugar
|
||||
return result;
|
||||
}
|
||||
}
|
||||
public class SubOrderByDesc : ISubOperation
|
||||
{
|
||||
public string Name
|
||||
{
|
||||
get { return "OrderByDesc"; }
|
||||
}
|
||||
|
||||
public Expression Expression
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public int Sort
|
||||
{
|
||||
get
|
||||
{
|
||||
return 480;
|
||||
}
|
||||
}
|
||||
|
||||
public ExpressionContext Context
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string GetValue(Expression expression)
|
||||
{
|
||||
var exp = expression as MethodCallExpression;
|
||||
var argExp = exp.Arguments[0];
|
||||
var result = "ORDER BY " + SubTools.GetMethodValue(this.Context, argExp, ResolveExpressType.FieldSingle)+" DESC";
|
||||
var selfParameterName = this.Context.GetTranslationColumnName((argExp as LambdaExpression).Parameters.First().Name) + UtilConstants.Dot;
|
||||
result = result.Replace(selfParameterName, string.Empty);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -22,7 +22,9 @@ namespace SqlSugar
|
||||
new SubFromTable(){ Context=Context },
|
||||
new SubCount(){ Context=Context },
|
||||
new SubMax(){ Context=Context },
|
||||
new SubMin(){ Context=Context }
|
||||
new SubMin(){ Context=Context },
|
||||
new SubOrderBy(){ Context=Context },
|
||||
new SubOrderByDesc(){ Context=Context }
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,14 @@ namespace SqlSugar
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public Subqueryable<T> OrderBy(Func<T, object> expression)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
public Subqueryable<T> OrderByDesc(Func<T, object> expression)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
public TResult Select<TResult>(Func<T, TResult> expression) where TResult :struct
|
||||
{
|
||||
return default(TResult);
|
||||
|
Reference in New Issue
Block a user