修改ClickHouse数据类型错误

This commit is contained in:
chenbo
2021-11-27 13:46:41 +08:00
parent d085acc4e9
commit c22d8d74d2
10 changed files with 318 additions and 218 deletions

View File

@ -201,7 +201,10 @@ namespace FreeSql.ClickHouse
return null;
}
var left = ExpressionLambdaToSql(exp.Expression, tsc);
if ((exp.Expression as MemberExpression)?.Expression.NodeType == ExpressionType.Constant)
left = $"toDateTime({left})";
//IsDate(left);
switch (exp.Member.Name)
{
case "Date": return $"toDate({left})";
@ -219,6 +222,19 @@ namespace FreeSql.ClickHouse
}
return null;
}
public bool IsInt(string _string)
{
if (string.IsNullOrEmpty(_string))
return false;
int i = 0;
return int.TryParse(_string, out i);
}
public bool IsDate(string date)
{
if (string.IsNullOrEmpty(date))
return true;
return DateTime.TryParse(date, out var time);
}
public override string ExpressionLambdaToSqlMemberAccessTimeSpan(MemberExpression exp, ExpTSC tsc)
{
if (exp.Expression == null)