Update mongodb

This commit is contained in:
sunkaixuan
2025-05-26 12:02:35 +08:00
parent 77ecdcbef5
commit 711085c72a
2 changed files with 29 additions and 3 deletions

View File

@@ -116,7 +116,15 @@ namespace MongoDbTest
Id = it.Id,
Name = it.Name+"b",
Name2 = "b"+it.Name
}).ToDataTable();
}).ToDataTable();
//var list13 = db.Queryable<OrderInfo>()
// .GroupBy(it=>it.Name)
// .Select(it => new
// {
// Id = it.Name,
// Name =SqlFunc.AggregateMax(it.Id)
// }).ToList();
//测试生成SQL性能
TestSqlBuilder(db);
}

View File

@@ -3,7 +3,7 @@ using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Linq;
namespace SqlSugar.MongoDb
{
public class MethodCallExpressionTractor
@@ -21,7 +21,25 @@ namespace SqlSugar.MongoDb
{
return BsonValue.Create(ExpressionTool.DynamicInvoke(expr));
}
return null;
else
{
var methodCallExpression = expr as MethodCallExpression;
var name = methodCallExpression.Method.Name;
BsonValue result = null;
if (typeof(IDbMethods).GetMethods().Any(it => it.Name == name))
{
var context = new MongoDbMethod();
MethodCallExpressionModel model = new MethodCallExpressionModel();
var args= methodCallExpression.Arguments;
foreach (var item in args)
{
//开发中
}
var funcString= context.GetType().GetMethod(name).Invoke(context, new object[] { model });
result = BsonValue.Create(funcString);
}
return result;
}
}
}
}