Update db.Reportable(DateOnly)

This commit is contained in:
sunkaixuan
2025-11-14 17:35:14 +08:00
parent be56cc3a02
commit 0895c84117
2 changed files with 3 additions and 1 deletions

View File

@@ -277,7 +277,7 @@ namespace SqlSugar
Args = new List<MethodCallExpressionArgs>() { Args = new List<MethodCallExpressionArgs>() {
new MethodCallExpressionArgs(){ new MethodCallExpressionArgs(){
IsMember=true, IsMember=true,
MemberName= formatBuilder.FormatValue(value) MemberName= formatBuilder.FormatValue(UtilMethods.DateOnlyToDateTime(value))
} }
} }
}); });

View File

@@ -1976,6 +1976,8 @@ namespace SqlSugar
internal static object DateOnlyToDateTime(object value) internal static object DateOnlyToDateTime(object value)
{ {
if (value is DateTime)
return value;
if (value == null) return null; if (value == null) return null;
var method = value.GetType().GetMethods().First(it => it.GetParameters().Length == 0 && it.Name == "ToShortDateString"); var method = value.GetType().GetMethods().First(it => it.GetParameters().Length == 0 && it.Name == "ToShortDateString");
return method.Invoke(value, new object[] { }); return method.Invoke(value, new object[] { });