Skip to content

Commit ddd5e81

Browse files
2881028810
authored andcommitted
update
1 parent e2d33e9 commit ddd5e81

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

FreeSql.Tests/UnitTest1.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public void Test1() {
201201
.Having(a => a.Count() > 0 && a.Avg(a.Key.mod4) > 0 && a.Max(a.Key.mod4) > 0)
202202
.Having(a => a.Count() < 300 || a.Avg(a.Key.mod4) < 100)
203203
.OrderBy(a => a.Key.tt2)
204-
.OrderByDescending(a => a.Count()).ToSql(a => new { a.Key.mod4, a.Key.tt2 });
204+
.OrderByDescending(a => a.Count()).ToSql(a => new { a.Key.mod4, a.Key.tt2, max = a.Max("a.id"), max2 = Convert.ToInt64("max(a.id)") });
205205

206206
var groupbysql2 = g.mysql.Select<TestInfo>().From<TestTypeInfo, TestTypeParentInfo>((s, b, c) => s
207207
.Where(a => a.Id == 1)

FreeSql/Internal/CommonExpression.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,14 @@ internal string ExpressionLambdaToSql(Expression exp, List<SelectTableInfo> _tab
345345
return $"{tmpleft} {tmptryoper} {tmpright}";
346346
}
347347
if (callType.FullName.StartsWith("FreeSql.ISelectGroupingAggregate`")) {
348+
//if (exp3.Type == typeof(string) && exp3.Arguments.Any() && exp3.Arguments[0].NodeType == ExpressionType.Constant) {
349+
// switch (exp3.Method.Name) {
350+
// case "Sum": return $"sum({(exp3.Arguments[0] as ConstantExpression)?.Value})";
351+
// case "Avg": return $"avg({(exp3.Arguments[0] as ConstantExpression)?.Value})";
352+
// case "Max": return $"max({(exp3.Arguments[0] as ConstantExpression)?.Value})";
353+
// case "Min": return $"min({(exp3.Arguments[0] as ConstantExpression)?.Value})";
354+
// }
355+
//}
348356
switch (exp3.Method.Name) {
349357
case "Count": return "count(1)";
350358
case "Sum": return $"sum({ExpressionLambdaToSql(exp3.Arguments[0], _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName, isDisableDiyParse, style)})";

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ using (var uow = fsql.CreateUnitOfWork()) {
114114
public class SongContext : DbContext {
115115

116116
public DbSet<Song> Songs { get; set; }
117-
public DbSet<Song> Tags { get; set; }
117+
public DbSet<Tag> Tags { get; set; }
118118

119119
protected override void OnConfiguring(DbContextOptionsBuilder builder) {
120120
builder.UseFreeSql(fsql);

0 commit comments

Comments
 (0)