mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 04:35:29 +08:00
Update mongodb
This commit is contained in:
parent
02a7772402
commit
019de80cf8
@ -33,8 +33,11 @@ namespace MongoDbTest
|
||||
new Student() { Age = 2, Name = "aa", SchoolId = "222", CreateDateTime = DateTime.Now.AddDays(-1) },
|
||||
new Student() { Age = 3, Name = "33", SchoolId = "333", CreateDateTime = DateTime.Now.AddDays(1) }
|
||||
}).ExecuteCommandAsync().GetAwaiter().GetResult();
|
||||
var id2 =db.Queryable<Student>().First(it => it.Name.ToLower() == "a")?.Id??null;
|
||||
db.Deleteable<Student>().In(id).ExecuteCommandAsync().GetAwaiter().GetResult();
|
||||
var id2 =db.Queryable<Student>().First(it => it.Name.ToLower() == "aa")?.Id??null;
|
||||
var count5=db.Queryable<Student>().Count();
|
||||
db.Deleteable<Student>().In(id2).ExecuteCommandAsync().GetAwaiter().GetResult();
|
||||
var count6 = db.Queryable<Student>().Count();
|
||||
if (count6 != (count5 - 1)) Cases.ThrowUnitError();
|
||||
}
|
||||
[SqlSugar.SugarTable("UnitStudent1ssdds3z1")]
|
||||
public class Student : MongoDbBase
|
||||
|
@ -22,7 +22,14 @@ namespace SqlSugar.MongoDb
|
||||
}
|
||||
|
||||
private static BsonDocument ComparisonNotKeyValue(BsonValue field, BsonValue value, string op)
|
||||
{
|
||||
{ // 如果 field 是一个表达式对象(如 BsonDocument),则使用 $expr
|
||||
if (field is BsonDocument bd)
|
||||
{
|
||||
return new BsonDocument
|
||||
{
|
||||
{ "$expr", new BsonDocument(op, new BsonArray { field, value }) }
|
||||
};
|
||||
}
|
||||
var leftKey = field.ToString();
|
||||
return new BsonDocument
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user