Update mongodb

This commit is contained in:
sunkaixuan 2025-06-20 19:53:35 +08:00
parent 8c177909d7
commit 02a7772402
2 changed files with 21 additions and 1 deletions

View File

@ -28,7 +28,13 @@ namespace MongoDbTest
if (count3 != 1) Cases.ThrowUnitError();
var rows3 = db.Deleteable<Student>().In(db.Queryable<Student>().First().Id).ExecuteCommandAsync().GetAwaiter().GetResult();
var count4 = db.Queryable<Student>().Count();
if (count4 !=0) Cases.ThrowUnitError();
if (count4 !=0) Cases.ThrowUnitError();
db.Insertable(new List<Student>() {
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();
}
[SqlSugar.SugarTable("UnitStudent1ssdds3z1")]
public class Student : MongoDbBase

View File

@ -486,6 +486,20 @@ namespace SqlSugar.MongoDb
throw new NotSupportedException("ToString 只支持0或1个参数");
}
}
public override string ToUpper(MethodCallExpressionModel model)
{
var item = model.DataObject as Expression;
BsonValue memberName = new ExpressionVisitor(context).Visit(item as Expression);
var toUpperDoc = new BsonDocument("$toUpper", $"${memberName}");
return toUpperDoc.ToJson(UtilMethods.GetJsonWriterSettings());
}
public override string ToLower(MethodCallExpressionModel model)
{
var item = model.DataObject as Expression;
BsonValue memberName = new ExpressionVisitor(context).Visit(item as Expression);
var toLowerDoc = new BsonDocument("$toLower", $"${memberName}");
return toLowerDoc.ToJson(UtilMethods.GetJsonWriterSettings());
}
#region