diff --git a/Src/Asp.NetCore2/ClickHouseTest/Demo/Demo0_SqlSugarClient.cs b/Src/Asp.NetCore2/ClickHouseTest/Demo/Demo0_SqlSugarClient.cs index 4076a3796..08a8bae56 100644 --- a/Src/Asp.NetCore2/ClickHouseTest/Demo/Demo0_SqlSugarClient.cs +++ b/Src/Asp.NetCore2/ClickHouseTest/Demo/Demo0_SqlSugarClient.cs @@ -107,7 +107,7 @@ namespace OrmTest var data6 = orderDb.GetPageList(it => it.Name == "xx", p, it => it.Name, OrderByType.Asc); Console.Write(p.TotalCount); List conModels = new List(); - 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); orderDb.AsQueryable().Where(x => x.Id == 1).ToList(); diff --git a/Src/Asp.NetCore2/ClickHouseTest/Demo/Demo1_Queryable.cs b/Src/Asp.NetCore2/ClickHouseTest/Demo/Demo1_Queryable.cs index 8987fce24..b58875c5c 100644 --- a/Src/Asp.NetCore2/ClickHouseTest/Demo/Demo1_Queryable.cs +++ b/Src/Asp.NetCore2/ClickHouseTest/Demo/Demo1_Queryable.cs @@ -58,7 +58,7 @@ namespace OrmTest var json = db.Queryable().ToJson(); - List listInt = db.Queryable().Select(it => it.Id).ToList(); + List listInt = db.Queryable().Select(it => it.Id).ToList(); var dynamic = db.Queryable().Select().ToList(); diff --git a/Src/Asp.NetCore2/ClickHouseTest/Models/Custom.cs b/Src/Asp.NetCore2/ClickHouseTest/Models/Custom.cs index 3b8871c57..0bc71a7c9 100644 --- a/Src/Asp.NetCore2/ClickHouseTest/Models/Custom.cs +++ b/Src/Asp.NetCore2/ClickHouseTest/Models/Custom.cs @@ -8,7 +8,8 @@ namespace OrmTest { public class Custom { - public int Id { get; set; } + + public long Id { get; set; } public string Name { get; set; } } } diff --git a/Src/Asp.NetCore2/ClickHouseTest/Models/Order.cs b/Src/Asp.NetCore2/ClickHouseTest/Models/Order.cs index d7ff068b8..871620098 100644 --- a/Src/Asp.NetCore2/ClickHouseTest/Models/Order.cs +++ b/Src/Asp.NetCore2/ClickHouseTest/Models/Order.cs @@ -9,15 +9,15 @@ namespace OrmTest public class Order { - [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] - public int Id { get; set; } + [SugarColumn(IsPrimaryKey = true)] + public long Id { get; set; } public string Name { get; set; } public decimal Price { get; set; } [SugarColumn(IsNullable = true)] public DateTime CreateTime { get; set; } [SugarColumn(IsNullable =true)] - public int CustomId { get; set; } + public long CustomId { get; set; } [SugarColumn(IsIgnore = true)] public List Items { get; set; } } diff --git a/Src/Asp.NetCore2/ClickHouseTest/Models/OrderItem.cs b/Src/Asp.NetCore2/ClickHouseTest/Models/OrderItem.cs index ae3262c7c..052e13bf5 100644 --- a/Src/Asp.NetCore2/ClickHouseTest/Models/OrderItem.cs +++ b/Src/Asp.NetCore2/ClickHouseTest/Models/OrderItem.cs @@ -8,9 +8,9 @@ namespace OrmTest [SqlSugar.SugarTable("OrderDetail")] public class OrderItem { - [SqlSugar.SugarColumn(IsPrimaryKey =true, IsIdentity =true)] - public int ItemId { get; set; } - public int OrderId { get; set; } + [SqlSugar.SugarColumn(IsPrimaryKey =true)] + public long ItemId { get; set; } + public long OrderId { get; set; } public decimal? Price { get; set; } [SqlSugar.SugarColumn(IsNullable = true)] public DateTime? CreateTime { get; set; } diff --git a/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/DbBind/ClickHouseDbBind.cs b/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/DbBind/ClickHouseDbBind.cs index 85164d688..f4c76747e 100644 --- a/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/DbBind/ClickHouseDbBind.cs +++ b/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/DbBind/ClickHouseDbBind.cs @@ -86,6 +86,7 @@ namespace SqlSugar.ClickHouse new KeyValuePair("Datetime64",CSharpDataType.DateTime), new KeyValuePair("Float64",CSharpDataType.@double), new KeyValuePair("Float32",CSharpDataType.@float), + new KeyValuePair("nullable",CSharpDataType.@object), }; public override List StringThrow { diff --git a/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/DbMaintenance/ClickHouseDbMaintenance.cs b/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/DbMaintenance/ClickHouseDbMaintenance.cs index e8e336bc8..c505d0c8b 100644 --- a/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/DbMaintenance/ClickHouseDbMaintenance.cs +++ b/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/DbMaintenance/ClickHouseDbMaintenance.cs @@ -60,7 +60,7 @@ namespace SqlSugar.ClickHouse { get { - return "ALTER TABLE {0} ADD PRIMARY KEY({2}) /*{1}*/"; + return ""; } } protected override string AddColumnToTableSql @@ -220,6 +220,10 @@ namespace SqlSugar.ClickHouse #endregion #region Methods + public override bool AddPrimaryKey(string tableName, string columnName) + { + return true; + } public override bool AddDefaultValue(string tableName, string columnName, string defaultValue) { return base.AddDefaultValue(this.SqlBuilder.GetTranslationTableName(tableName), this.SqlBuilder.GetTranslationTableName(columnName), defaultValue); @@ -324,6 +328,7 @@ namespace SqlSugar.ClickHouse List columnArray = new List(); Check.Exception(columns.IsNullOrEmpty(), "No columns found "); var pkName = ""; + var isLower = ((ClickHouseBuilder)this.SqlBuilder).isAutoToLower; foreach (var item in columns) { string columnName = item.DbColumnName; @@ -339,14 +344,14 @@ namespace SqlSugar.ClickHouse } string nullType = item.IsNullable ? this.CreateTableNull : CreateTableNotNull; 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); if (pkName.IsNullOrEmpty()&&item.IsPrimarykey) { 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()) { pkName = this.SqlBuilder.GetTranslationColumnName(pkName); diff --git a/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/SqlBuilder/ClickHouseExpressionContext.cs b/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/SqlBuilder/ClickHouseExpressionContext.cs index 8b3694f60..9dfb8499b 100644 --- a/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/SqlBuilder/ClickHouseExpressionContext.cs +++ b/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/ClickHouse/SqlBuilder/ClickHouseExpressionContext.cs @@ -4,7 +4,7 @@ namespace SqlSugar.ClickHouse { public class ClickHouseExpressionContext : ExpressionContext, ILambdaExpressions { - public SqlSugarProvider Context { get; set; } + public SqlSugarProvider Context { get; set; } = new SqlSugarProvider(new ConnectionConfig() { }); public ClickHouseExpressionContext() { base.DbMehtods = new ClickHouseMethod(); @@ -31,7 +31,7 @@ namespace SqlSugar.ClickHouse { get { - return base.PgSqlIsAutoToLower; + return false; } } public override string GetTranslationTableName(string entityName, bool isMapping = true) diff --git a/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/Tools/UtilExtensions.cs b/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/Tools/UtilExtensions.cs index e7083f526..b4be13408 100644 --- a/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/Tools/UtilExtensions.cs +++ b/Src/Asp.NetCore2/SqlSugar.ClickHouseCore/Tools/UtilExtensions.cs @@ -11,7 +11,11 @@ namespace SqlSugar.ClickHouse { 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) {