mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 10:08:19 +08:00
Update mongodb
This commit is contained in:
@@ -260,7 +260,8 @@ namespace SqlSugar.MongoDb
|
||||
name = "ToDate";
|
||||
if (name == "Contains" && methodCallExpression.Arguments.Count == 1
|
||||
&& methodCallExpression?.Object?.Type != null
|
||||
&& typeof(IEnumerable).IsAssignableFrom(methodCallExpression.Object.Type))
|
||||
&& typeof(IEnumerable).IsAssignableFrom(methodCallExpression.Object.Type)
|
||||
&& methodCallExpression.Object.Type!=UtilConstants.StringType)
|
||||
{
|
||||
name = "ContainsArray";
|
||||
}
|
||||
|
@@ -736,6 +736,16 @@ namespace SqlSugar.MongoDb
|
||||
var inDoc = new BsonDocument(name, new BsonDocument("$in", bsonArray));
|
||||
return inDoc.ToJson(UtilMethods.GetJsonWriterSettings());
|
||||
}
|
||||
else if (ExpressionTool.GetParameters(itemExp).Count == 0)
|
||||
{
|
||||
// itemExp 是常量表达式,arrayExp 是字段表达式
|
||||
var value =UtilMethods.MyCreate(ExpressionTool.DynamicInvoke(itemExp));
|
||||
BsonValue arrayField = new ExpressionVisitor(context).Visit(arrayExp);
|
||||
|
||||
// 构建 MongoDB $in 查询表达式,判断 value 是否在 arrayField 字段数组中
|
||||
var inDoc = new BsonDocument(arrayField.ToString(), new BsonDocument( "$in",new BsonArray() { value } ));
|
||||
return inDoc.ToJson(UtilMethods.GetJsonWriterSettings());
|
||||
}
|
||||
else
|
||||
{
|
||||
// 数组表达式不是常量,需生成MongoDB $in表达式,数组字段为arrayExp,判断itemExp是否在数组中
|
||||
@@ -744,7 +754,7 @@ namespace SqlSugar.MongoDb
|
||||
// 获取数组字段名
|
||||
BsonValue arrayField = new ExpressionVisitor(context).Visit(arrayExp);
|
||||
// 构建MongoDB的 $in 查询表达式,格式为 { "$in": [ "$_id", "$$let_RoleIds" ] }
|
||||
var inArray = new BsonArray { name, arrayField };
|
||||
var inArray = new BsonArray { name, arrayField };
|
||||
var inDoc = new BsonDocument("$in", inArray);
|
||||
return inDoc.ToJson(UtilMethods.GetJsonWriterSettings());
|
||||
}
|
||||
|
@@ -308,7 +308,7 @@ namespace SqlSugar.MongoDb
|
||||
|
||||
// $unwind
|
||||
BsonValue unwindDoc = null;
|
||||
if (item.JoinType == JoinType.Left&&isEasyJoin)
|
||||
if (item.JoinType == JoinType.Left)
|
||||
{
|
||||
unwindDoc = new BsonDocument("$unwind", new BsonDocument
|
||||
{
|
||||
|
Reference in New Issue
Block a user