Update xx.date

This commit is contained in:
skx
2020-11-22 23:03:27 +08:00
parent 8ec30f403a
commit 49e284ca58
2 changed files with 8 additions and 18 deletions

View File

@@ -135,10 +135,10 @@ namespace OrmTest
Id = SqlFunc.AggregateSum(SqlFunc.IF(it.Id > 0).Return(1).End(0))
}).ToList();
var list2 = db.Queryable<Order>().Select(it => new
var list2 = db.Queryable<Order>().Where(it=>it.CreateTime.Date==it.CreateTime).Select(it => new
{
date = SqlFunc.ToDateShort(it.CreateTime),
datetime = SqlFunc.ToDate(it.CreateTime)
date = it.CreateTime.Date,
datetime = DateTime.Now.Date
}).ToList();
Console.WriteLine("#### SqlFunc End ####");
}

View File

@@ -178,12 +178,7 @@ namespace SqlSugar
var value = GetNewExpressionValue(expression.Expression);
if (expression.Member.Name == "Date")
{
AppendMember(parameter, isLeft, GetToDate(this.Context.DbMehtods.MergeString(
this.GetDateValue(value, DateType.Year),
"'-'",
this.GetDateValue(value, DateType.Month),
"'-'",
this.GetDateValue(value, DateType.Day))));
AppendMember(parameter, isLeft, GetToDateShort(value));
}
else
{
@@ -292,12 +287,7 @@ namespace SqlSugar
new MethodCallExpressionArgs() { MemberName=DateType.Year, MemberValue=DateType.Year}
}
};
AppendMember(parameter, isLeft, GetToDate(this.Context.DbMehtods.MergeString(
this.GetDateValue(parameter.CommonTempData, DateType.Year),
"'-'",
this.GetDateValue(parameter.CommonTempData, DateType.Month),
"'-'",
this.GetDateValue(parameter.CommonTempData, DateType.Day))));
AppendMember(parameter, isLeft, GetToDateShort(parameter.CommonTempData.ObjToString()));
}
parameter.CommonTempData = oldCommonTempDate;
}
@@ -456,7 +446,7 @@ namespace SqlSugar
return this.Context.DbMehtods.DateValue(pars);
}
private string GetToDate(string value)
private string GetToDateShort(string value)
{
var pars = new MethodCallExpressionModel()
{
@@ -464,7 +454,7 @@ namespace SqlSugar
new MethodCallExpressionArgs() { MemberName=value, MemberValue=value },
}
};
return this.Context.DbMehtods.ToDate(pars);
return this.Context.DbMehtods.ToDateShort(pars);
}
private void SettingParameters(ExpressionParameter parameter, out ExpressionParameter baseParameter, out MemberExpression expression, out bool? isLeft, out bool isSetTempData, out bool isValue, out bool isValueBool, out bool isLength, out bool isDateValue, out bool isHasValue, out bool isDateDate, out bool isMemberValue, out bool isSingle, out bool fieldIsBool, out bool isSelectField, out bool isField)