mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-23 12:33:44 +08:00
Update mongodb
This commit is contained in:
@@ -179,12 +179,12 @@ namespace MongoDbTest
|
||||
}).ToList();
|
||||
if (list19.Max(it => it.name) != true) Cases.ThrowUnitError();
|
||||
|
||||
//var list20 = db.Queryable<Student>()
|
||||
// .Select(it => new
|
||||
// {
|
||||
// name = string.IsNullOrEmpty(it.Name).ToString(),
|
||||
// }).ToList();
|
||||
//if (list20.Max(it => it.name) != "true") Cases.ThrowUnitError();
|
||||
var list20 = db.Queryable<Student>()
|
||||
.Select(it => new
|
||||
{
|
||||
name = string.IsNullOrEmpty(it.Name).ToString(),
|
||||
}).ToList();
|
||||
if (list20.Max(it => it.name) != "true") Cases.ThrowUnitError();
|
||||
|
||||
var list22= db.Queryable<Student>()
|
||||
.Select(it=>it.Name).ToList();
|
||||
|
@@ -448,7 +448,7 @@ namespace SqlSugar.MongoDb
|
||||
if (model.Args == null || model.Args.Count == 0)
|
||||
{
|
||||
// 只有 ToString(),直接转字符串
|
||||
var toStringDoc = new BsonDocument("$toString", $"${memberName}");
|
||||
var toStringDoc = new BsonDocument("$toString", GetMemberName(memberName));
|
||||
return toStringDoc.ToJson(UtilMethods.GetJsonWriterSettings());
|
||||
}
|
||||
else if (model.Args.Count == 1)
|
||||
@@ -597,8 +597,13 @@ namespace SqlSugar.MongoDb
|
||||
}
|
||||
|
||||
#region Helper
|
||||
|
||||
// Existing methods...
|
||||
private static BsonValue GetMemberName(BsonValue memberName)
|
||||
{
|
||||
if (memberName is BsonDocument)
|
||||
return memberName;
|
||||
else
|
||||
return $"${memberName}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a C# date format string to a MongoDB-compatible date format string.
|
||||
|
Reference in New Issue
Block a user