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);
|
||||
}
|
||||
var isJoin = this._context.queryBuilder?.IsSingle()==false;
|
||||
var isJoin = this._context?.queryBuilder?.IsSingle()==false;
|
||||
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;
|
||||
if (joinInfo != null)
|
||||
{
|
||||
|
@@ -104,26 +104,18 @@ namespace SqlSugar.MongoDb
|
||||
|
||||
foreach (var col in group)
|
||||
{
|
||||
|
||||
if (col.DbColumnName.EqualCase("_id") || col.DataType == nameof(ObjectId))
|
||||
if (pks.Any(s=>s.EqualCase(col.DbColumnName)))
|
||||
{
|
||||
if (col.Value == null)
|
||||
{
|
||||
filter[col.DbColumnName] = UtilMethods.MyCreate(col.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
filter[col.DbColumnName] = UtilMethods.MyCreate(ObjectId.Parse(col.Value?.ToString()));
|
||||
}
|
||||
filter[col.DbColumnName] = UtilMethods.MyCreate(col.Value,col);
|
||||
}
|
||||
else if (col.IsJson)
|
||||
{
|
||||
var bsonValue = UtilMethods.ParseJsonObject(col.Value?.ToString());
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -508,6 +508,20 @@ namespace SqlSugar.MongoDb
|
||||
else
|
||||
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)
|
||||
//{
|
||||
// var item = new ConditionalModel() {
|
||||
|
Reference in New Issue
Block a user