mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
Update mongodb
This commit is contained in:
parent
056245e676
commit
12ae51653c
@ -106,6 +106,12 @@ namespace MongoDbTest
|
||||
if (list10.First().Age4 != 100) Cases.ThrowUnitError();
|
||||
if (list10.First().Age5 != 11) Cases.ThrowUnitError();
|
||||
if (list10.First().Age6 != 1) Cases.ThrowUnitError();
|
||||
|
||||
var list11 = db.Queryable<Student>().Select(it => new
|
||||
{
|
||||
Age = it.Age > 0 ? it.Age +1: 1,
|
||||
}).ToList();
|
||||
if (list11.First().Age != 12) Cases.ThrowUnitError();
|
||||
}
|
||||
[SqlSugar.SugarTable("UnitStudent1231sds3z1")]
|
||||
public class Student : MongoDbBase
|
||||
|
@ -17,12 +17,23 @@ namespace SqlSugar.MongoDb
|
||||
else
|
||||
return GetCommonCalculation(field, value, operation);
|
||||
}
|
||||
private static BsonDocument GetCommonCalculation(BsonValue field, BsonValue value, string operation)
|
||||
private BsonDocument GetCommonCalculation(BsonValue field, BsonValue value, string operation)
|
||||
{
|
||||
return new BsonDocument
|
||||
if (_visitorContext?.IsText == true)
|
||||
{
|
||||
// 三元条件格式: { "$gt": ["$Age", 0] }
|
||||
return new BsonDocument
|
||||
{
|
||||
{ operation, new BsonArray { "$" + field, value } }
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return new BsonDocument
|
||||
{
|
||||
{ field.ToString(), new BsonDocument { { operation, value } } }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static BsonDocument StringAddCalculation(BsonValue field, BsonValue value, bool leftIsMember, bool rightIsMember, out string operation)
|
||||
|
Loading…
Reference in New Issue
Block a user