mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
Update ClickHouse
This commit is contained in:
parent
74398420c3
commit
bf853eac7b
@ -107,7 +107,7 @@ namespace OrmTest
|
|||||||
var data6 = orderDb.GetPageList(it => it.Name == "xx", p, it => it.Name, OrderByType.Asc);
|
var data6 = orderDb.GetPageList(it => it.Name == "xx", p, it => it.Name, OrderByType.Asc);
|
||||||
Console.Write(p.TotalCount);
|
Console.Write(p.TotalCount);
|
||||||
List<IConditionalModel> conModels = new List<IConditionalModel>();
|
List<IConditionalModel> conModels = new List<IConditionalModel>();
|
||||||
conModels.Add(new ConditionalModel() { FieldName = "id", ConditionalType = ConditionalType.Equal, FieldValue = "1", FieldValueConvertFunc=it=>Convert.ToInt32(it) });//id=1
|
conModels.Add(new ConditionalModel() { FieldName = "Id", ConditionalType = ConditionalType.Equal, FieldValue = "1", FieldValueConvertFunc=it=>Convert.ToInt32(it) });//id=1
|
||||||
var data7 = orderDb.GetPageList(conModels, p, it => it.Name, OrderByType.Asc);
|
var data7 = orderDb.GetPageList(conModels, p, it => it.Name, OrderByType.Asc);
|
||||||
orderDb.AsQueryable().Where(x => x.Id == 1).ToList();
|
orderDb.AsQueryable().Where(x => x.Id == 1).ToList();
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ namespace OrmTest
|
|||||||
|
|
||||||
var json = db.Queryable<Order>().ToJson();
|
var json = db.Queryable<Order>().ToJson();
|
||||||
|
|
||||||
List<int> listInt = db.Queryable<Order>().Select(it => it.Id).ToList();
|
List<long> listInt = db.Queryable<Order>().Select(it => it.Id).ToList();
|
||||||
|
|
||||||
var dynamic = db.Queryable<Order>().Select<dynamic>().ToList();
|
var dynamic = db.Queryable<Order>().Select<dynamic>().ToList();
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@ namespace OrmTest
|
|||||||
{
|
{
|
||||||
public class Custom
|
public class Custom
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
|
||||||
|
public long Id { get; set; }
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,15 +9,15 @@ namespace OrmTest
|
|||||||
|
|
||||||
public class Order
|
public class Order
|
||||||
{
|
{
|
||||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
[SugarColumn(IsPrimaryKey = true)]
|
||||||
public int Id { get; set; }
|
public long Id { get; set; }
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public decimal Price { get; set; }
|
public decimal Price { get; set; }
|
||||||
[SugarColumn(IsNullable = true)]
|
[SugarColumn(IsNullable = true)]
|
||||||
public DateTime CreateTime { get; set; }
|
public DateTime CreateTime { get; set; }
|
||||||
[SugarColumn(IsNullable =true)]
|
[SugarColumn(IsNullable =true)]
|
||||||
public int CustomId { get; set; }
|
public long CustomId { get; set; }
|
||||||
[SugarColumn(IsIgnore = true)]
|
[SugarColumn(IsIgnore = true)]
|
||||||
public List<OrderItem> Items { get; set; }
|
public List<OrderItem> Items { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,9 @@ namespace OrmTest
|
|||||||
[SqlSugar.SugarTable("OrderDetail")]
|
[SqlSugar.SugarTable("OrderDetail")]
|
||||||
public class OrderItem
|
public class OrderItem
|
||||||
{
|
{
|
||||||
[SqlSugar.SugarColumn(IsPrimaryKey =true, IsIdentity =true)]
|
[SqlSugar.SugarColumn(IsPrimaryKey =true)]
|
||||||
public int ItemId { get; set; }
|
public long ItemId { get; set; }
|
||||||
public int OrderId { get; set; }
|
public long OrderId { get; set; }
|
||||||
public decimal? Price { get; set; }
|
public decimal? Price { get; set; }
|
||||||
[SqlSugar.SugarColumn(IsNullable = true)]
|
[SqlSugar.SugarColumn(IsNullable = true)]
|
||||||
public DateTime? CreateTime { get; set; }
|
public DateTime? CreateTime { get; set; }
|
||||||
|
@ -86,6 +86,7 @@ namespace SqlSugar.ClickHouse
|
|||||||
new KeyValuePair<string, CSharpDataType>("Datetime64",CSharpDataType.DateTime),
|
new KeyValuePair<string, CSharpDataType>("Datetime64",CSharpDataType.DateTime),
|
||||||
new KeyValuePair<string, CSharpDataType>("Float64",CSharpDataType.@double),
|
new KeyValuePair<string, CSharpDataType>("Float64",CSharpDataType.@double),
|
||||||
new KeyValuePair<string, CSharpDataType>("Float32",CSharpDataType.@float),
|
new KeyValuePair<string, CSharpDataType>("Float32",CSharpDataType.@float),
|
||||||
|
new KeyValuePair<string, CSharpDataType>("nullable",CSharpDataType.@object),
|
||||||
};
|
};
|
||||||
public override List<string> StringThrow
|
public override List<string> StringThrow
|
||||||
{
|
{
|
||||||
|
@ -60,7 +60,7 @@ namespace SqlSugar.ClickHouse
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return "ALTER TABLE {0} ADD PRIMARY KEY({2}) /*{1}*/";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override string AddColumnToTableSql
|
protected override string AddColumnToTableSql
|
||||||
@ -220,6 +220,10 @@ namespace SqlSugar.ClickHouse
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
public override bool AddPrimaryKey(string tableName, string columnName)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
public override bool AddDefaultValue(string tableName, string columnName, string defaultValue)
|
public override bool AddDefaultValue(string tableName, string columnName, string defaultValue)
|
||||||
{
|
{
|
||||||
return base.AddDefaultValue(this.SqlBuilder.GetTranslationTableName(tableName), this.SqlBuilder.GetTranslationTableName(columnName), defaultValue);
|
return base.AddDefaultValue(this.SqlBuilder.GetTranslationTableName(tableName), this.SqlBuilder.GetTranslationTableName(columnName), defaultValue);
|
||||||
@ -324,6 +328,7 @@ namespace SqlSugar.ClickHouse
|
|||||||
List<string> columnArray = new List<string>();
|
List<string> columnArray = new List<string>();
|
||||||
Check.Exception(columns.IsNullOrEmpty(), "No columns found ");
|
Check.Exception(columns.IsNullOrEmpty(), "No columns found ");
|
||||||
var pkName = "";
|
var pkName = "";
|
||||||
|
var isLower = ((ClickHouseBuilder)this.SqlBuilder).isAutoToLower;
|
||||||
foreach (var item in columns)
|
foreach (var item in columns)
|
||||||
{
|
{
|
||||||
string columnName = item.DbColumnName;
|
string columnName = item.DbColumnName;
|
||||||
@ -339,14 +344,14 @@ namespace SqlSugar.ClickHouse
|
|||||||
}
|
}
|
||||||
string nullType = item.IsNullable ? this.CreateTableNull : CreateTableNotNull;
|
string nullType = item.IsNullable ? this.CreateTableNull : CreateTableNotNull;
|
||||||
string primaryKey = "";
|
string primaryKey = "";
|
||||||
string addItem = string.Format(this.CreateTableColumn, this.SqlBuilder.GetTranslationColumnName(columnName.ToLower()), dataType, dataSize, nullType, primaryKey, "");
|
string addItem = string.Format(this.CreateTableColumn, this.SqlBuilder.GetTranslationColumnName(columnName.ToLower(isLower)), dataType, dataSize, nullType, primaryKey, "");
|
||||||
columnArray.Add(addItem);
|
columnArray.Add(addItem);
|
||||||
if (pkName.IsNullOrEmpty()&&item.IsPrimarykey)
|
if (pkName.IsNullOrEmpty()&&item.IsPrimarykey)
|
||||||
{
|
{
|
||||||
pkName = item.DbColumnName;
|
pkName = item.DbColumnName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
string tableString = string.Format(this.CreateTableSql, this.SqlBuilder.GetTranslationTableName(tableName.ToLower()), string.Join(",\r\n", columnArray));
|
string tableString = string.Format(this.CreateTableSql, this.SqlBuilder.GetTranslationTableName(tableName.ToLower(isLower)), string.Join(",\r\n", columnArray));
|
||||||
if (pkName.HasValue())
|
if (pkName.HasValue())
|
||||||
{
|
{
|
||||||
pkName = this.SqlBuilder.GetTranslationColumnName(pkName);
|
pkName = this.SqlBuilder.GetTranslationColumnName(pkName);
|
||||||
|
@ -4,7 +4,7 @@ namespace SqlSugar.ClickHouse
|
|||||||
{
|
{
|
||||||
public class ClickHouseExpressionContext : ExpressionContext, ILambdaExpressions
|
public class ClickHouseExpressionContext : ExpressionContext, ILambdaExpressions
|
||||||
{
|
{
|
||||||
public SqlSugarProvider Context { get; set; }
|
public SqlSugarProvider Context { get; set; } = new SqlSugarProvider(new ConnectionConfig() { });
|
||||||
public ClickHouseExpressionContext()
|
public ClickHouseExpressionContext()
|
||||||
{
|
{
|
||||||
base.DbMehtods = new ClickHouseMethod();
|
base.DbMehtods = new ClickHouseMethod();
|
||||||
@ -31,7 +31,7 @@ namespace SqlSugar.ClickHouse
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return base.PgSqlIsAutoToLower;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override string GetTranslationTableName(string entityName, bool isMapping = true)
|
public override string GetTranslationTableName(string entityName, bool isMapping = true)
|
||||||
|
@ -11,7 +11,11 @@ namespace SqlSugar.ClickHouse
|
|||||||
{
|
{
|
||||||
public static string ToLower(this string value, bool isLower)
|
public static string ToLower(this string value, bool isLower)
|
||||||
{
|
{
|
||||||
return value.ObjToString().ToLower();
|
if (isLower)
|
||||||
|
{
|
||||||
|
return value.ObjToString().ToLower();
|
||||||
|
}
|
||||||
|
return value.ObjToString();
|
||||||
}
|
}
|
||||||
public static int ObjToInt(this object thisValue)
|
public static int ObjToInt(this object thisValue)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user