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
2244cd40d2
commit
755d9af8c6
@ -14,9 +14,17 @@ namespace MongoDbTest
|
||||
internal static void Init()
|
||||
{
|
||||
var db = DBHelper.DbHelper.GetNewDb();
|
||||
db.CodeFirst.InitTables<Student>();
|
||||
db.CodeFirst.InitTables<Student>();
|
||||
db.DbMaintenance.TruncateTable<Student>();
|
||||
db.Storageable(new Student() { Name = "a", SchoolId = "1", CreateDateTime = DateTime.Now })
|
||||
.ExecuteCommand();
|
||||
var datas=db.Queryable<Student>().ToList();
|
||||
if (datas.Count != 1) Cases.ThrowUnitError();
|
||||
datas.First().Name = "aaa";
|
||||
db.Storageable(datas).ExecuteCommand();
|
||||
var datas2 = db.Queryable<Student>().ToList();
|
||||
if (datas2.Count != 1) Cases.ThrowUnitError();
|
||||
if (datas2.First().Name != "aaa") Cases.ThrowUnitError();
|
||||
}
|
||||
[SqlSugar.SugarTable("UnitStudent1zzsds3z1")]
|
||||
public class Student : MongoDbBase
|
||||
|
@ -43,6 +43,10 @@ namespace SqlSugar.MongoDb
|
||||
}
|
||||
else
|
||||
{
|
||||
if (column.IsPrimarykey&& value!=null)
|
||||
{
|
||||
value = ObjectId.Parse(value?.ToString());
|
||||
}
|
||||
bsonValue = BsonValue.Create(value);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user