mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-22 20:13:41 +08:00
Update Mongodb
This commit is contained in:
@@ -127,6 +127,17 @@ namespace MongoDbTest
|
||||
max=SqlFunc.AggregateMax(it.Id),
|
||||
min=SqlFunc.AggregateMin(it.Id)
|
||||
}).ToList();
|
||||
|
||||
var list14 = db.Queryable<OrderInfo>()
|
||||
.GroupBy(it => new { it.Name ,it.Price })
|
||||
.Select(it => new
|
||||
{
|
||||
key = it.Name,
|
||||
Prie=it.Price,
|
||||
groupCount = SqlFunc.AggregateCount(it.Id),
|
||||
max = SqlFunc.AggregateMax(it.Id),
|
||||
min = SqlFunc.AggregateMin(it.Id)
|
||||
}).ToList();
|
||||
//测试生成SQL性能
|
||||
TestSqlBuilder(db);
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
using MongoDbTest;
|
||||
//MongoDb还在开发中预计5月30号前可以使用
|
||||
//MongoDb还在开发中预计6月30号前可以使用
|
||||
OrmTest.Init();
|
||||
AdoTest.Init();
|
||||
ExpTest.Init();
|
||||
|
@@ -116,7 +116,6 @@ namespace SqlSugar.MongoDb
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Select
|
||||
if (this.SelectValue is Expression expression)
|
||||
{
|
||||
@@ -130,7 +129,6 @@ namespace SqlSugar.MongoDb
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region GroupBy
|
||||
if (this.GroupByValue.HasValue())
|
||||
{
|
||||
@@ -144,17 +142,20 @@ namespace SqlSugar.MongoDb
|
||||
var selectItem = match.Groups[1].Value;
|
||||
selectItems.Add(selectItem);
|
||||
}
|
||||
var jsonPart = Regex.Split(this.GroupByValue, UtilConstants.ReplaceCommaKey)
|
||||
var jsonPart = "["+Regex.Split(this.GroupByValue, UtilConstants.ReplaceCommaKey)
|
||||
.First()
|
||||
.TrimEnd('(')
|
||||
.Replace("GROUP BY ", "");
|
||||
.Replace("GROUP BY ", "")+"]";
|
||||
var fieldNames = new List<string>();
|
||||
var bson = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(jsonPart);
|
||||
if (bson.Contains("fieldName"))
|
||||
var bsonArray = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonArray>(jsonPart);
|
||||
foreach (BsonDocument bson in bsonArray)
|
||||
{
|
||||
var field = bson["fieldName"].AsString;
|
||||
operations[operations.Count - 1] = operations[operations.Count - 1].Replace($"\"${field}\"", $"\"$_id.{field}\"");
|
||||
fieldNames.Add(field);
|
||||
if (bson.Contains("fieldName"))
|
||||
{
|
||||
var field = bson["fieldName"].AsString;
|
||||
operations[operations.Count - 1] = operations[operations.Count - 1].Replace($"\"${field}\"", $"\"$_id.{field}\"");
|
||||
fieldNames.Add(field);
|
||||
}
|
||||
}
|
||||
// 构造 _id 部分:支持多字段形式
|
||||
var groupId = new BsonDocument();
|
||||
|
Reference in New Issue
Block a user