Update mongodb

This commit is contained in:
sunkaixuan
2025-06-30 16:14:39 +08:00
parent ecad4e36a8
commit 8e0fadea40
2 changed files with 18 additions and 2 deletions

View File

@@ -91,6 +91,15 @@ namespace MongoDbTest
}).ToList();
if (dt6.Count != 1 || dt6.Last().studentName != "李四" || dt6.Last().schoolName != "复旦大学") Cases.ThrowUnitError();
var dt7 = db.Queryable<Student>()
.LeftJoin<School>((s, sc) => s.SchoolId == sc.Id && sc.Name == "复旦大学")
.Select((s, sc) => new
{
studentName = s.Name,
schoolName = sc.Name
}).ToList();
if (dt7.Count != 1 || dt7.Last().studentName != "李四" || dt7.Last().schoolName != "复旦大学") Cases.ThrowUnitError();
}
[SqlSugar.SugarTable("UnitStudentdu2s31")]
public class Student : MongoDbBase

View File

@@ -263,7 +263,7 @@ namespace SqlSugar.MongoDb
// $unwind
BsonValue unwindDoc = null;
if (item.JoinType == JoinType.Left)
if (item.JoinType == JoinType.Left&&isEasyJoin)
{
unwindDoc = new BsonDocument("$unwind", new BsonDocument
{
@@ -271,7 +271,14 @@ namespace SqlSugar.MongoDb
{ "preserveNullAndEmptyArrays", true }
});
}
else if (item.JoinType == JoinType.Inner)
else if (item.JoinType == JoinType.Inner && isEasyJoin)
{
unwindDoc = new BsonDocument("$unwind", new BsonDocument
{
{ "path", $"${asName}" }
});
}
else if (isExp)
{
unwindDoc = new BsonDocument("$unwind", new BsonDocument
{