Browse Source

Update ClickHouse

SqlSugar5
sunkaixuan 2 years ago
parent
commit
f29ee041d7
  1. 1
      Src/Asp.NetCore2/ClickHouseTest/Demo/Demo1_Queryable.cs
  2. 36
      Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/SqlBuilder/ClickHouseExpressionContext.cs

1
Src/Asp.NetCore2/ClickHouseTest/Demo/Demo1_Queryable.cs

@ -39,6 +39,7 @@ namespace OrmTest
var getAll7 = db.Queryable<Order>().Select(x => x.Name.ToString()).ToList(); var getAll7 = db.Queryable<Order>().Select(x => x.Name.ToString()).ToList();
var getAll8 = db.Queryable<Order>().Select(x => x.CreateTime.ToString("yyyy-MM-dd")).ToList(); var getAll8 = db.Queryable<Order>().Select(x => x.CreateTime.ToString("yyyy-MM-dd")).ToList();
var getAll9 = db.Queryable<Order>().Select(x => x.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")).ToList(); var getAll9 = db.Queryable<Order>().Select(x => x.CreateTime.ToString("yyyy-MM-dd HH:mm:ss")).ToList();
var getAl20 = db.Queryable<Order>().Select(x => x.CreateTime.Year).ToList();
var getOrderBy = db.Queryable<Order>().OrderBy(it => it.Name,OrderByType.Desc).ToList(); var getOrderBy = db.Queryable<Order>().OrderBy(it => it.Name,OrderByType.Desc).ToList();
var getOrderBy2 = db.Queryable<Order>().OrderBy(it => it.Id).OrderBy(it => it.Name, OrderByType.Desc).ToList(); var getOrderBy2 = db.Queryable<Order>().OrderBy(it => it.Id).OrderBy(it => it.Name, OrderByType.Desc).ToList();
var getOrderBy3 = db.Queryable<Order>().OrderBy(it =>new { it.Name,it.Id}).ToList(); var getOrderBy3 = db.Queryable<Order>().OrderBy(it =>new { it.Name,it.Id}).ToList();

36
Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/SqlBuilder/ClickHouseExpressionContext.cs

@ -184,41 +184,9 @@ namespace SqlSugar.ClickHouse
{ {
var parameter = model.Args[0]; var parameter = model.Args[0];
var parameter2 = model.Args[1]; var parameter2 = model.Args[1];
var format = "dd";
if (parameter2.MemberValue.ObjToString() == DateType.Year.ToString())
{
format = "yyyy";
}
if (parameter2.MemberValue.ObjToString() == DateType.Month.ToString())
{
format = "MM";
}
if (parameter2.MemberValue.ObjToString() == DateType.Day.ToString())
{
format = "dd";
}
if (parameter2.MemberValue.ObjToString() == DateType.Hour.ToString())
{
format = "hh";
}
if (parameter2.MemberValue.ObjToString() == DateType.Minute.ToString())
{
format = "mi";
}
if (parameter2.MemberValue.ObjToString() == DateType.Second.ToString())
{
format = "ss";
}
if (parameter2.MemberValue.ObjToString() == DateType.Millisecond.ToString())
{
format = "ms";
}
if (parameter2.MemberValue.ObjToString() == DateType.Weekday.ToString())
{
return $" extract(DOW FROM cast({parameter.MemberName} as TIMESTAMP)) ";
}
return string.Format(" cast( to_char({1},'{0}')as integer ) ", format, parameter.MemberName); return string.Format(" to{0}({1}) ", parameter2.MemberValue.ObjToString(), parameter.MemberName);
} }
public override string Contains(MethodCallExpressionModel model) public override string Contains(MethodCallExpressionModel model)

Loading…
Cancel
Save