mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 13:06:50 +08:00
Update clickhouse
This commit is contained in:
parent
31609a18dd
commit
f72dbb7a14
@ -21,12 +21,45 @@ namespace OrmTest
|
||||
});
|
||||
//db.DbMaintenance.CreateDatabase();
|
||||
db.CodeFirst.InitTables(typeof(CodeFirstTable1));//Create CodeFirstTable1
|
||||
db.Insertable(new CodeFirstTable1() { Name = "a", Text="a" }).ExecuteCommand();
|
||||
db.Insertable(new CodeFirstTable1() { Name = "a", Text = "a" }).ExecuteCommand();
|
||||
var list = db.Queryable<CodeFirstTable1>().ToList();
|
||||
TestBool(db);
|
||||
TestGuid(db);
|
||||
Console.WriteLine("#### CodeFirst end ####");
|
||||
}
|
||||
private static void TestGuid(SqlSugarClient db)
|
||||
{
|
||||
db.CodeFirst.InitTables<GuidTest>();
|
||||
db.DbMaintenance.TruncateTable("BoolTest");
|
||||
var Id = 1;
|
||||
db.Insertable<GuidTest>(new GuidTest() { A = Guid.Empty, Id = Id }).ExecuteCommand();
|
||||
Console.Write(db.Queryable<GuidTest>().First().A);
|
||||
db.Updateable<GuidTest>(new GuidTest() { A = Guid.NewGuid(), Id = Id }).ExecuteCommand();
|
||||
Console.Write(db.Queryable<GuidTest>().First().A);
|
||||
}
|
||||
private static void TestBool(SqlSugarClient db)
|
||||
{
|
||||
db.CodeFirst.InitTables<BoolTest>();
|
||||
db.DbMaintenance.TruncateTable("BoolTest");
|
||||
var Id = 1;
|
||||
db.Insertable<BoolTest>(new BoolTest() { A = true, Id = Id }).ExecuteCommand();
|
||||
Console.Write(db.Queryable<BoolTest>().First().A);
|
||||
db.Updateable<BoolTest>(new BoolTest() { A = false, Id = Id }).ExecuteCommand();
|
||||
Console.Write(db.Queryable<BoolTest>().First().A);
|
||||
}
|
||||
}
|
||||
public class GuidTest
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
public Guid A { get; set; }
|
||||
}
|
||||
public class BoolTest
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey =true)]
|
||||
public long Id { get; set; }
|
||||
public bool A { get; set; }
|
||||
}
|
||||
|
||||
public class CodeFirstTable1
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
|
@ -125,10 +125,18 @@ namespace SqlSugar.ClickHouse
|
||||
{
|
||||
dbtype = ClickHouseDbBind.MappingTypesConst.First(it => it.Value == CSharpDataType.@decimal).Key;
|
||||
}
|
||||
if (dbtype.ObjToString() == System.Data.DbType.Boolean.ToString())
|
||||
if (dbtype.ObjToString() == System.Data.DbType.Guid.ToString())
|
||||
{
|
||||
dbtype = ClickHouseDbBind.MappingTypesConst.First(it => it.Value == CSharpDataType.Guid).Key;
|
||||
}
|
||||
if (param.Value!=null&¶m.Value!=DBNull.Value&&dbtype.ObjToString() == System.Data.DbType.Boolean.ToString())
|
||||
{
|
||||
sql = sql.Replace(param.ParameterName, param.Value.ObjToBool()?"1":"0");
|
||||
}
|
||||
else if (dbtype.ObjToString() == System.Data.DbType.Boolean.ToString())
|
||||
{
|
||||
sql = sql.Replace(param.ParameterName, "null");
|
||||
}
|
||||
else
|
||||
{
|
||||
sql = sql.Replace(param.ParameterName, "{" + newName + ":" + dbtype + "}");
|
||||
|
Loading…
Reference in New Issue
Block a user