mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2026-02-27 16:50:33 +08:00
Update mongodb
This commit is contained in:
@@ -21,11 +21,16 @@ namespace MongoDbTest
|
||||
var student = new Student { Name = "TestStudent", SchoolId = ids.Last() };
|
||||
db.Insertable(student).ExecuteCommand();
|
||||
// 添加学生数据,SchoolId 关联学校并且没有学校
|
||||
var student2 = new Student { Name = "TestStudent", SchoolId =
|
||||
var student2 = new Student { Name = "TestStudentNoSchool", SchoolId =
|
||||
ObjectId.GenerateNewId().ToString()
|
||||
};
|
||||
db.Insertable(student2).ExecuteCommand();
|
||||
|
||||
|
||||
if (db.Queryable<Student>().First(it => it.SchoolId == ids.Last()).Name != "TestStudent") Cases.ThrowUnitError();
|
||||
db.Updateable(db.Queryable<Student>().First(it => it.SchoolId == ids.Last())).ExecuteCommand();
|
||||
if (db.Queryable<Student>().First(it => it.SchoolId == ids.Last()).Name != "TestStudent") Cases.ThrowUnitError();
|
||||
|
||||
//var list=db.Queryable<Student>()
|
||||
// .LeftJoin<School>((x, y) => x.SchoolId == y.Id)
|
||||
// .Where((x,y)=>x.Name =="a"||y.Name=="a")
|
||||
@@ -38,7 +43,7 @@ namespace MongoDbTest
|
||||
public class Student : MongoDbBase
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
[SqlSugar.SugarColumn(ColumnDataType =nameof(ObjectId))]
|
||||
public string SchoolId { get; set; }
|
||||
}
|
||||
[SqlSugar.SugarTable("UnitSchool123131")]
|
||||
|
||||
Reference in New Issue
Block a user