mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-20 18:48:09 +08:00
Update mongodb
This commit is contained in:
@@ -260,7 +260,8 @@ namespace SqlSugar.MongoDb
|
|||||||
name = "ToDate";
|
name = "ToDate";
|
||||||
if (name == "Contains" && methodCallExpression.Arguments.Count == 1
|
if (name == "Contains" && methodCallExpression.Arguments.Count == 1
|
||||||
&& methodCallExpression?.Object?.Type != null
|
&& methodCallExpression?.Object?.Type != null
|
||||||
&& typeof(IEnumerable).IsAssignableFrom(methodCallExpression.Object.Type))
|
&& typeof(IEnumerable).IsAssignableFrom(methodCallExpression.Object.Type)
|
||||||
|
&& methodCallExpression.Object.Type!=UtilConstants.StringType)
|
||||||
{
|
{
|
||||||
name = "ContainsArray";
|
name = "ContainsArray";
|
||||||
}
|
}
|
||||||
|
@@ -736,6 +736,16 @@ namespace SqlSugar.MongoDb
|
|||||||
var inDoc = new BsonDocument(name, new BsonDocument("$in", bsonArray));
|
var inDoc = new BsonDocument(name, new BsonDocument("$in", bsonArray));
|
||||||
return inDoc.ToJson(UtilMethods.GetJsonWriterSettings());
|
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
|
else
|
||||||
{
|
{
|
||||||
// 数组表达式不是常量,需生成MongoDB $in表达式,数组字段为arrayExp,判断itemExp是否在数组中
|
// 数组表达式不是常量,需生成MongoDB $in表达式,数组字段为arrayExp,判断itemExp是否在数组中
|
||||||
|
@@ -308,7 +308,7 @@ namespace SqlSugar.MongoDb
|
|||||||
|
|
||||||
// $unwind
|
// $unwind
|
||||||
BsonValue unwindDoc = null;
|
BsonValue unwindDoc = null;
|
||||||
if (item.JoinType == JoinType.Left&&isEasyJoin)
|
if (item.JoinType == JoinType.Left)
|
||||||
{
|
{
|
||||||
unwindDoc = new BsonDocument("$unwind", new BsonDocument
|
unwindDoc = new BsonDocument("$unwind", new BsonDocument
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user