diff --git a/Src/Asp.Net/MySqlTest/Demo/Demo1_Queryable.cs b/Src/Asp.Net/MySqlTest/Demo/Demo1_Queryable.cs index 3b40db731..e10f4f2f0 100644 --- a/Src/Asp.Net/MySqlTest/Demo/Demo1_Queryable.cs +++ b/Src/Asp.Net/MySqlTest/Demo/Demo1_Queryable.cs @@ -41,6 +41,7 @@ namespace OrmTest var getByWhere = db.Queryable().Where(it => it.Id == 1 || it.Name == "a").ToList(); var getByWhere2 = db.Queryable().Where(it => it.Id == DateTime.Now.Year).ToList(); var getByFuns = db.Queryable().Where(it => SqlFunc.IsNullOrEmpty(it.Name)).ToList(); + var getByFuns2 = db.Queryable().GroupBy(it=>it.Name).Select(it=>SqlFunc.AggregateDistinctCount(it.Price)).ToList(); Console.WriteLine("#### Examples End ####"); } diff --git a/Src/Asp.Net/SqlServerTest/Demo/Demo1_Queryable.cs b/Src/Asp.Net/SqlServerTest/Demo/Demo1_Queryable.cs index 16512f7ef..bc6789f5c 100644 --- a/Src/Asp.Net/SqlServerTest/Demo/Demo1_Queryable.cs +++ b/Src/Asp.Net/SqlServerTest/Demo/Demo1_Queryable.cs @@ -41,6 +41,7 @@ namespace OrmTest var getByWhere = db.Queryable().Where(it => it.Id == 1 || it.Name == "a").ToList(); var getByWhere2 = db.Queryable().Where(it => it.Id == DateTime.Now.Year).ToList(); var getByFuns = db.Queryable().Where(it => SqlFunc.IsNullOrEmpty(it.Name)).ToList(); + var getByFuns2 = db.Queryable().GroupBy(it => it.Name).Select(it => SqlFunc.AggregateDistinctCount(it.Price)).ToList(); Console.WriteLine("#### Examples End ####"); } diff --git a/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs b/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs index 74a199270..a3aefd70b 100644 --- a/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs +++ b/Src/Asp.Net/SqlSugar/ExpressionsToSql/DbMethods/SqlFunc.cs @@ -101,6 +101,7 @@ namespace SqlSugar public static TResult AggregateMin(TResult thisValue) { throw new NotSupportedException("Can only be used in expressions"); } public static TResult AggregateMax(TResult thisValue) { throw new NotSupportedException("Can only be used in expressions"); } public static int AggregateCount(TResult thisValue) { throw new NotSupportedException("Can only be used in expressions"); } + public static int AggregateDistinctCount(TResult thisValue) { throw new NotSupportedException("Can only be used in expressions"); } public static TResult MappingColumn(TResult oldColumnName,string newColumnName) { throw new NotSupportedException("Can only be used in expressions"); } /// ///Example: new NewT(){name=SqlFunc.GetSelfAndAutoFill(it)} Generated SQL it.*