mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-07 07:04:32 +08:00
Update mongodb
This commit is contained in:
@@ -147,6 +147,12 @@ namespace SqlSugar.MongoDb
|
||||
return arrayObj;
|
||||
}
|
||||
}
|
||||
internal static object DateOnlyToDateTime(object value)
|
||||
{
|
||||
if (value == null) return null;
|
||||
var method = value.GetType().GetMethods().First(it => it.GetParameters().Length == 0 && it.Name == "ToShortDateString");
|
||||
return method.Invoke(value, new object[] { });
|
||||
}
|
||||
public static BsonValue MyCreate(object value)
|
||||
{
|
||||
if (value is DateTime dt)
|
||||
@@ -162,6 +168,10 @@ namespace SqlSugar.MongoDb
|
||||
{
|
||||
value = ObjectId.Parse(s);
|
||||
}
|
||||
else if (value!=null&&value?.GetType()?.Name=="DateOnly")
|
||||
{
|
||||
value = Convert.ToDateTime(DateOnlyToDateTime(value)).ToString("yyyy-MM-dd");
|
||||
}
|
||||
return BsonValue.Create(value);
|
||||
}
|
||||
internal static MongoDB.Bson.IO.JsonWriterSettings GetJsonWriterSettings()
|
||||
|
Reference in New Issue
Block a user