Update mongodb

This commit is contained in:
sunkaixuan
2025-07-05 13:22:33 +08:00
parent 662b9ba07e
commit e9dea98978
3 changed files with 17 additions and 1 deletions

View File

@@ -205,6 +205,12 @@ namespace MongoDbTest
Age2 =SqlFunc.IIF( it.Age > 0 , it.Age ,1), Age2 =SqlFunc.IIF( it.Age > 0 , it.Age ,1),
}).ToList(); }).ToList();
if (list26.First().Age1 != list26.First().Age2) Cases.ThrowUnitError(); if (list26.First().Age1 != list26.First().Age2) Cases.ThrowUnitError();
var id = db.Queryable<Student>().First().Id;
var data1 = db.Queryable<Student>().Where(it=>it.Id==id).Single();
var data2=db.Queryable<Student>().InSingle(id);
var data3 = db.Queryable<Student>().InSingleAsync(id).GetAwaiter().GetResult();
if (data1.Id != data2.Id || data2.Id != data3.Id) Cases.ThrowUnitError();
} }
[SqlSugar.SugarTable("UnitStudent1231sds3z1")] [SqlSugar.SugarTable("UnitStudent1231sds3z1")]
public class Student : MongoDbBase public class Student : MongoDbBase

View File

@@ -12,6 +12,16 @@ namespace SqlSugar.MongoDb
{ {
public class MongoDbQueryable<T> : QueryableProvider<T> public class MongoDbQueryable<T> : QueryableProvider<T>
{ {
public override T InSingle(object pkValue)
{
this.Where("{ \"_id\" : { \"$oid\" : \""+pkValue+"\" } }");
return this.Single();
}
public override Task<T> InSingleAsync(object pkValue)
{
this.Where("{ \"_id\" : { \"$oid\" : \"" + pkValue + "\" } }");
return this.SingleAsync();
}
public override JoinQueryInfo GetJoinInfo(Expression joinExpression, JoinType joinType) public override JoinQueryInfo GetJoinInfo(Expression joinExpression, JoinType joinType)
{ {
return BuildJoinQueryInfo(joinExpression, joinType); return BuildJoinQueryInfo(joinExpression, joinType);

View File

@@ -2,7 +2,7 @@
<package > <package >
<metadata> <metadata>
<id>SqlSugarCore</id> <id>SqlSugarCore</id>
<version>5.1.4.198-preview07</version> <version>5.1.4.198-preview09</version>
<authors>sunkaixuan</authors> <authors>sunkaixuan</authors>
<owners>果糖大数据科技</owners> <owners>果糖大数据科技</owners>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl> <licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>