This commit is contained in:
sunkaixuan
2017-07-14 01:42:25 +08:00
parent 7f9b3a8f68
commit d86a08e208
3 changed files with 20 additions and 8 deletions

View File

@@ -122,14 +122,17 @@ namespace OrmTest.Demo
var list2 = db.Queryable<Student>()
.GroupBy(it => new { it.Id, it.Name }).Having(it => SqlFunc.AggregateAvg(it.Id) > 0)
.Select(it => new { idAvg = SqlFunc.AggregateAvg(it.Id), name = it.Name }).ToList();
//SQL:
//SELECT AVG([Id]) AS[idAvg], [Name] AS[name] FROM[Student] GROUP BY[Name],[Id] HAVING(AVG([Id]) > 0 )
// group id,name take first
var list3 = db.Queryable<Student>()
.PartitionBy(it => new { it.Id, it.Name }).Take(1).ToList();
int count = 0;
//SQL:
//SELECT AVG([Id]) AS[idAvg], [Name] AS[name] FROM[Student] GROUP BY[Name],[Id] HAVING(AVG([Id]) > 0 )
var list4 = db.Queryable<Student>()
.PartitionBy(it => new { it.Id, it.Name }).Take(1).ToPageList(2,3,ref count);
//SqlFunc.AggregateSum(object thisValue)
//SqlFunc.AggregateAvg<TResult>(TResult thisValue)