mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-24 08:33:16 +08:00
Update mongodb
This commit is contained in:
@@ -177,12 +177,20 @@ namespace SqlSugar.MongoDb
|
||||
jsonPart = str;
|
||||
directionPart = "ASC";
|
||||
}
|
||||
var bson = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(jsonPart);
|
||||
if (bson.Contains(UtilConstants.FieldName))
|
||||
if (jsonPart?.StartsWith("{") == false && jsonPart?.StartsWith("[") == false)
|
||||
{
|
||||
var field = bson[UtilConstants.FieldName].AsString;
|
||||
var direction = directionPart == "DESC" ? -1 : 1;
|
||||
sortDoc[field] = direction;
|
||||
sortDoc[jsonPart?.Replace(" ASC","")?.TrimEnd('\"')?.TrimStart('\"')] = direction;
|
||||
}
|
||||
else
|
||||
{
|
||||
var bson = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(jsonPart);
|
||||
if (bson.Contains(UtilConstants.FieldName))
|
||||
{
|
||||
var field = bson[UtilConstants.FieldName].AsString;
|
||||
var direction = directionPart == "DESC" ? -1 : 1;
|
||||
sortDoc[field] = direction;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sortDoc.ElementCount > 0)
|
||||
|
||||
Reference in New Issue
Block a user