mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
Update mongodb
This commit is contained in:
parent
a65c2740c3
commit
feb5d298e1
@ -31,12 +31,38 @@ namespace MongoDbTest
|
|||||||
db.Updateable(db.Queryable<Student>().First(it => it.SchoolId == ids.Last())).ExecuteCommand();
|
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();
|
if (db.Queryable<Student>().First(it => it.SchoolId == ids.Last()).Name != "TestStudent") Cases.ThrowUnitError();
|
||||||
|
|
||||||
//var list=db.Queryable<Student>()
|
var adoTest= db.Ado.GetDataTable(@"aggregate UnitStudent123131 [
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: ""UnitSchool123131"",
|
||||||
|
localField: ""SchoolId"",
|
||||||
|
foreignField: ""_id"",
|
||||||
|
as: ""y""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$unwind: {
|
||||||
|
path: ""$y"",
|
||||||
|
preserveNullAndEmptyArrays: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$project: {
|
||||||
|
_id: 0,
|
||||||
|
StudentName: ""$Name"",
|
||||||
|
SchoolName: {
|
||||||
|
$ifNull: [""$y.Name"", null]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]");
|
||||||
|
|
||||||
|
//var list = db.Queryable<Student>()
|
||||||
// .LeftJoin<School>((x, y) => x.SchoolId == y.Id)
|
// .LeftJoin<School>((x, y) => x.SchoolId == y.Id)
|
||||||
// .Where((x,y)=>x.Name =="a"||y.Name=="a")
|
// .Select((x,y) => new
|
||||||
// .Select(x => new
|
|
||||||
// {
|
// {
|
||||||
// id=x.Name
|
// StudentName= x.Name,
|
||||||
|
// SchoolName= y.Name
|
||||||
// }).ToList();
|
// }).ToList();
|
||||||
}
|
}
|
||||||
[SqlSugar.SugarTable("UnitStudent123131")]
|
[SqlSugar.SugarTable("UnitStudent123131")]
|
||||||
|
Loading…
Reference in New Issue
Block a user