Update Mongodb

This commit is contained in:
sunkaixuan
2025-05-04 18:39:11 +08:00
parent 5bc23c8d0f
commit 411e186788
18 changed files with 83 additions and 77 deletions

View File

@@ -9,8 +9,8 @@ namespace MongoDbTest
public class OrderInfo
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true,ColumnName ="_Id")]
public int Id { get; set; }
[SugarColumn(IsPrimaryKey = true, IsOnlyIgnoreInsert =true)]
public string Id { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }

View File

@@ -15,10 +15,13 @@ namespace MongoDbTest
var db = DbHelper.GetNewDb();
db.Insertable(new OrderInfo() { CreateTime = DateTime.Now, Name = "a", Price = 1 })
.ExecuteCommand();
db.Insertable(new List<OrderInfo>(){
var ids= db.Insertable(new List<OrderInfo>(){
new OrderInfo() { CreateTime = DateTime.Now, Name = "a1", Price = 2 },
new OrderInfo() { CreateTime = DateTime.Now, Name = "a2", Price = 3 }})
.ExecuteCommand();
.ExecuteReturnPkList<string>();
db.Deleteable(new OrderInfo() { Id="a" })
.ExecuteCommand();
}
}
}