Update mongodb

This commit is contained in:
sunkaixuan
2025-06-15 09:05:52 +08:00
parent 44e251d8fb
commit 06d2db0368
2 changed files with 64 additions and 1 deletions

View File

@@ -18,7 +18,7 @@ namespace MongoDbTest
db.CodeFirst.InitTables<Student>();
db.DbMaintenance.TruncateTable<Student>();
var dt = DateTime.Now;
var studentId = db.Insertable(new Student() { CreateDateTime=dt, Name="a", SchoolId="aa" })
var studentId = db.Insertable(new Student() { CreateDateTime=dt,Age=11, Name="a", SchoolId="aa" })
.ExecuteCommand();
var list=db.Queryable<Student>().Select(it => new
{
@@ -42,6 +42,10 @@ namespace MongoDbTest
date = it.CreateDateTime.ToString("yyyy-MM-dd")
}).ToList();
if(list2.First().date!=dt.ToString("yyyy-MM-dd")) Cases.ThrowUnitError();
var list3 = db.Queryable<Student>().Select(it => new
{
date = it.Age.ToString()
}).ToList();
}
[SqlSugar.SugarTable("UnitStudent1231sds3z1")]
public class Student : MongoDbBase
@@ -50,6 +54,8 @@ namespace MongoDbTest
public string SchoolId { get; set; }
public int Age { get; set; }
public DateTime CreateDateTime { get; set; }
}
}