mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-20 10:38:09 +08:00
Update mongodb
This commit is contained in:
@@ -120,9 +120,9 @@ namespace SqlSugar.MongoDb
|
|||||||
{
|
{
|
||||||
resultString = string.Join(".", parts);
|
resultString = string.Join(".", parts);
|
||||||
}
|
}
|
||||||
var isJoin = this._context.queryBuilder?.IsSingle()==false;
|
var isJoin = this._context?.queryBuilder?.IsSingle()==false;
|
||||||
var shortName = ((ParameterExpression)expr)?.Name;
|
var shortName = ((ParameterExpression)expr)?.Name;
|
||||||
var joinInfo = this._context.queryBuilder?.JoinQueryInfos?.FirstOrDefault(it => it.ShortName.EqualCase(shortName));
|
var joinInfo = this._context?.queryBuilder?.JoinQueryInfos?.FirstOrDefault(it => it.ShortName.EqualCase(shortName));
|
||||||
var isObj = false;
|
var isObj = false;
|
||||||
if (joinInfo != null)
|
if (joinInfo != null)
|
||||||
{
|
{
|
||||||
|
@@ -103,27 +103,19 @@ namespace SqlSugar.MongoDb
|
|||||||
var setDoc = new BsonDocument();
|
var setDoc = new BsonDocument();
|
||||||
|
|
||||||
foreach (var col in group)
|
foreach (var col in group)
|
||||||
{
|
{
|
||||||
|
if (pks.Any(s=>s.EqualCase(col.DbColumnName)))
|
||||||
if (col.DbColumnName.EqualCase("_id") || col.DataType == nameof(ObjectId))
|
|
||||||
{
|
{
|
||||||
if (col.Value == null)
|
filter[col.DbColumnName] = UtilMethods.MyCreate(col.Value,col);
|
||||||
{
|
|
||||||
filter[col.DbColumnName] = UtilMethods.MyCreate(col.Value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
filter[col.DbColumnName] = UtilMethods.MyCreate(ObjectId.Parse(col.Value?.ToString()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (col.IsJson)
|
else if (col.IsJson)
|
||||||
{
|
{
|
||||||
var bsonValue = UtilMethods.ParseJsonObject(col.Value?.ToString());
|
var bsonValue = UtilMethods.ParseJsonObject(col.Value?.ToString());
|
||||||
setDoc[col.DbColumnName] = bsonValue;
|
setDoc[col.DbColumnName] = bsonValue;
|
||||||
}
|
}
|
||||||
else
|
else if(col.IsPrimarykey==false)
|
||||||
{
|
{
|
||||||
var bsonValue = UtilMethods.MyCreate(col.Value);
|
var bsonValue = UtilMethods.MyCreate(col.Value, col);
|
||||||
setDoc[col.DbColumnName] = bsonValue;
|
setDoc[col.DbColumnName] = bsonValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -508,6 +508,20 @@ namespace SqlSugar.MongoDb
|
|||||||
else
|
else
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static BsonValue MyCreate(object value, DbColumnInfo col)
|
||||||
|
{
|
||||||
|
if (value != null&&IsObjectColumn(col))
|
||||||
|
{
|
||||||
|
return MyCreate(ObjectId.Parse(value?.ToString()));
|
||||||
|
}
|
||||||
|
return MyCreate(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsObjectColumn(DbColumnInfo col)
|
||||||
|
{
|
||||||
|
return col.DbColumnName == "_id" || col.DataType == nameof(ObjectId);
|
||||||
|
}
|
||||||
//public static object ConvertDataByTypeName(string ctypename,string value)
|
//public static object ConvertDataByTypeName(string ctypename,string value)
|
||||||
//{
|
//{
|
||||||
// var item = new ConditionalModel() {
|
// var item = new ConditionalModel() {
|
||||||
|
Reference in New Issue
Block a user