- 增加 实体属性 char 类型的映射#381 #235;

This commit is contained in:
28810 2020-07-22 09:44:12 +08:00
parent cd60c9dbd9
commit 72739a27c6
53 changed files with 232 additions and 502 deletions

View File

@ -282,57 +282,7 @@ namespace FreeSql.Tests.MySqlConnector
{
var sql = g.mysql.CodeFirst.GetComparisonDDLStatements<TableAllType>();
if (string.IsNullOrEmpty(sql) == false)
{
Assert.Equal(@"CREATE TABLE IF NOT EXISTS `cccddd`.`tb_alltype` (
`Id` INT(11) NOT NULL AUTO_INCREMENT,
`testFieldBool` BIT(1) NOT NULL,
`testFieldSByte` TINYINT(3) NOT NULL,
`testFieldShort` SMALLINT(6) NOT NULL,
`testFieldInt` INT(11) NOT NULL,
`testFieldLong` BIGINT(20) NOT NULL,
`testFieldByte` TINYINT(3) UNSIGNED NOT NULL,
`testFieldUShort` SMALLINT(5) UNSIGNED NOT NULL,
`testFieldUInt` INT(10) UNSIGNED NOT NULL,
`testFieldULong` BIGINT(20) UNSIGNED NOT NULL,
`testFieldDouble` DOUBLE NOT NULL,
`testFieldFloat` FLOAT NOT NULL,
`testFieldDecimal` DECIMAL(10,2) NOT NULL,
`testFieldTimeSpan` TIME NOT NULL,
`testFieldDateTime` DATETIME(3) NOT NULL,
`testFieldBytes` VARBINARY(255),
`testFieldString` VARCHAR(255),
`testFieldGuid` VARCHAR(36),
`testFieldBoolNullable` BIT(1),
`testFieldSByteNullable` TINYINT(3),
`testFieldShortNullable` SMALLINT(6),
`testFieldIntNullable` INT(11),
`testFielLongNullable` BIGINT(20),
`testFieldByteNullable` TINYINT(3) UNSIGNED,
`testFieldUShortNullable` SMALLINT(5) UNSIGNED,
`testFieldUIntNullable` INT(10) UNSIGNED,
`testFieldULongNullable` BIGINT(20) UNSIGNED,
`testFieldDoubleNullable` DOUBLE,
`testFieldFloatNullable` FLOAT,
`testFieldDecimalNullable` DECIMAL(10,2),
`testFieldTimeSpanNullable` TIME,
`testFieldDateTimeNullable` DATETIME(3),
`testFieldGuidNullable` VARCHAR(36),
`testFieldPoint` POINT,
`testFieldLineString` LINESTRING,
`testFieldPolygon` POLYGON,
`testFieldMultiPoint` MULTIPOINT,
`testFieldMultiLineString` MULTILINESTRING,
`testFieldMultiPolygon` MULTIPOLYGON,
`testFieldEnum1` ENUM('E1','E2','E3') NOT NULL,
`testFieldEnum1Nullable` ENUM('E1','E2','E3'),
`testFieldEnum2` SET('F1','F2','F3') NOT NULL,
`testFieldEnum2Nullable` SET('F1','F2','F3'),
PRIMARY KEY (`Id`)
) Engine=InnoDB;
", sql);
}
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
sql = g.mysql.CodeFirst.GetComparisonDDLStatements<Tb_alltype>();
}
@ -398,6 +348,7 @@ namespace FreeSql.Tests.MySqlConnector
testFieldShort = short.MaxValue,
testFieldShortNullable = short.MinValue,
testFieldString = "ÎÒÊÇÖйúÈËstring'\\?!@#$%^&*()_+{}}{~?><<>",
testFieldChar = 'X',
testFieldTimeSpan = TimeSpan.FromSeconds(999),
testFieldTimeSpanNullable = TimeSpan.FromSeconds(60),
testFieldUInt = uint.MaxValue,
@ -411,10 +362,12 @@ namespace FreeSql.Tests.MySqlConnector
item2.Id = (int)insert.AppendData(item2).ExecuteIdentity();
var newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
item2.Id = (int)insert.NoneParameter().AppendData(item2).ExecuteIdentity();
newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
var items = select.ToList();
var itemstb = select.ToDataTable();
@ -561,6 +514,10 @@ namespace FreeSql.Tests.MySqlConnector
public string TestFieldString { get; set; }
[JsonProperty, Column(Name = "testFieldChar", DbType = "char(1)", IsNullable = true)]
public char testFieldChar { get; set; }
[JsonProperty, Column(Name = "testFieldTimeSpan", DbType = "time")]
public TimeSpan TestFieldTimeSpan { get; set; }
@ -665,6 +622,7 @@ namespace FreeSql.Tests.MySqlConnector
public byte[] testFieldBytes { get; set; }
public string testFieldString { get; set; }
public char testFieldChar { get; set; }
public Guid testFieldGuid { get; set; }
public bool? testFieldBoolNullable { get; set; }

View File

@ -179,57 +179,7 @@ namespace FreeSql.Tests.Odbc.Dameng
{
var sql = g.dameng.CodeFirst.GetComparisonDDLStatements<TableAllType>();
if (string.IsNullOrEmpty(sql) == false)
{
Assert.Equal(@"CREATE TABLE IF NOT EXISTS `cccddd`.`tb_alltype` (
`Id` INT(11) NOT NULL AUTO_INCREMENT,
`Bool` BIT(1) NOT NULL,
`SByte` TINYINT(3) NOT NULL,
`Short` SMALLINT(6) NOT NULL,
`Int` INT(11) NOT NULL,
`Long` BIGINT(20) NOT NULL,
`Byte` TINYINT(3) UNSIGNED NOT NULL,
`UShort` SMALLINT(5) UNSIGNED NOT NULL,
`UInt` INT(10) UNSIGNED NOT NULL,
`ULong` BIGINT(20) UNSIGNED NOT NULL,
`Double` DOUBLE NOT NULL,
`Float` FLOAT NOT NULL,
`Decimal` DECIMAL(10,2) NOT NULL,
`TimeSpan` TIME NOT NULL,
`DateTime` DATETIME NOT NULL,
`Bytes` VARBINARY(255),
`String` VARCHAR(255),
`Guid` VARCHAR(36),
`BoolNullable` BIT(1),
`SByteNullable` TINYINT(3),
`ShortNullable` SMALLINT(6),
`IntNullable` INT(11),
`testFielLongNullable` BIGINT(20),
`ByteNullable` TINYINT(3) UNSIGNED,
`UShortNullable` SMALLINT(5) UNSIGNED,
`UIntNullable` INT(10) UNSIGNED,
`ULongNullable` BIGINT(20) UNSIGNED,
`DoubleNullable` DOUBLE,
`FloatNullable` FLOAT,
`DecimalNullable` DECIMAL(10,2),
`TimeSpanNullable` TIME,
`DateTimeNullable` DATETIME,
`GuidNullable` VARCHAR(36),
`Point` POINT,
`LineString` LINESTRING,
`Polygon` POLYGON,
`MultiPoint` MULTIPOINT,
`MultiLineString` MULTILINESTRING,
`MultiPolygon` MULTIPOLYGON,
`Enum1` ENUM('E1','E2','E3') NOT NULL,
`Enum1Nullable` ENUM('E1','E2','E3'),
`Enum2` SET('F1','F2','F3') NOT NULL,
`Enum2Nullable` SET('F1','F2','F3'),
PRIMARY KEY (`Id`)
) Engine=InnoDB;
", sql);
}
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
//sql = g.dameng.CodeFirst.GetComparisonDDLStatements<Tb_alltype>();
}
@ -272,6 +222,7 @@ namespace FreeSql.Tests.Odbc.Dameng
Short = short.MaxValue,
ShortNullable = short.MinValue,
String = "ÎÒÊÇÖйúÈËstring'\\?!@#$%^&*()_+{}}{~?><<>",
Char = 'X',
TimeSpan = TimeSpan.FromSeconds(999),
TimeSpanNullable = TimeSpan.FromSeconds(60),
UInt = uint.MaxValue,
@ -289,10 +240,12 @@ namespace FreeSql.Tests.Odbc.Dameng
item2.Id = (int)insert.AppendData(item2).ExecuteIdentity();
var newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.String, newitem2.String);
Assert.Equal(item2.Char, newitem2.Char);
item2.Id = (int)insert.NoneParameter().AppendData(item2).ExecuteIdentity();
newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.String, newitem2.String);
Assert.Equal(item2.Char, newitem2.Char);
var items = select.ToList();
var itemstb = select.ToDataTable();
@ -323,6 +276,7 @@ namespace FreeSql.Tests.Odbc.Dameng
public DateTime DateTimeOffSet { get; set; }
public byte[] Bytes { get; set; }
public string String { get; set; }
public char Char { get; set; }
public Guid Guid { get; set; }
public bool? BoolNullable { get; set; }

View File

@ -99,6 +99,7 @@ namespace FreeSql.Tests.Odbc.Default
testFieldShort = short.MaxValue,
testFieldShortNullable = short.MinValue,
testFieldString = "我是中国人string'\\?!@#$%^&*()_+{}}{~?><<>",
testFieldChar = 'X',
testFieldUInt = uint.MaxValue,
testFieldUIntNullable = uint.MinValue,
testFieldULong = ulong.MaxValue,
@ -117,10 +118,12 @@ namespace FreeSql.Tests.Odbc.Default
var item3 = insert.AppendData(item2).ExecuteIdentity();
var newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
item2.Id = (int)insert.NoneParameter().AppendData(item2).ExecuteIdentity();
newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
var items = select.ToList();
var itemstb = select.ToDataTable();
@ -148,6 +151,7 @@ namespace FreeSql.Tests.Odbc.Default
public DateTime testFieldDateTime { get; set; }
public byte[] testFieldBytes { get; set; }
public string testFieldString { get; set; }
public char testFieldChar { get; set; }
public Guid testFieldGuid { get; set; }
public bool? testFieldBoolNullable { get; set; }

View File

@ -177,8 +177,8 @@ namespace FreeSql.Tests.Odbc.KingbaseES
[Fact]
public void GetComparisonDDLStatements()
{
var sql = g.kingbaseES.CodeFirst.GetComparisonDDLStatements<TableAllType>();
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
//sql = g.kingbaseES.CodeFirst.GetComparisonDDLStatements<Tb_alltype>();
}
@ -221,6 +221,7 @@ namespace FreeSql.Tests.Odbc.KingbaseES
Short = short.MaxValue,
ShortNullable = short.MinValue,
String = "ÎÒÊÇÖйúÈËstring'\\?!@#$%^&*()_+{}}{~?><<>",
Char = 'X',
TimeSpan = TimeSpan.FromSeconds(999),
TimeSpanNullable = TimeSpan.FromSeconds(60),
UInt = uint.MaxValue,
@ -255,19 +256,22 @@ namespace FreeSql.Tests.Odbc.KingbaseES
a.DateTimeOffSet,
a.Bytes,
a.String,
a.Char,
a.Guid
});
var newitem22 = select.Where(a => a.Id == item2.Id).First(a => new
{
a.Id, a.id2, a.SByte, a.Short, a.Int, a.Long, a.Byte, a.UShort, a.UInt, a.ULong, a.Double, a.Float, a.Decimal, a.TimeSpan, a.DateTime, a.DateTimeOffSet, a.Bytes, a.String, a.Guid
a.Id, a.id2, a.SByte, a.Short, a.Int, a.Long, a.Byte, a.UShort, a.UInt, a.ULong, a.Double, a.Float, a.Decimal, a.TimeSpan, a.DateTime, a.DateTimeOffSet, a.Bytes, a.String, a.Char, a.Guid
});
var newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.String, newitem2.String);
Assert.Equal(item2.Char, newitem2.Char);
item2.Id = (int)insert.NoneParameter().AppendData(item2).ExecuteIdentity();
newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.String, newitem2.String);
Assert.Equal(item2.Char, newitem2.Char);
var items = select.ToList();
var itemstb = select.ToDataTable();
@ -298,6 +302,7 @@ namespace FreeSql.Tests.Odbc.KingbaseES
public DateTime DateTimeOffSet { get; set; }
public byte[] Bytes { get; set; }
public string String { get; set; }
public char Char { get; set; }
public Guid Guid { get; set; }
public bool? BoolNullable { get; set; }

View File

@ -153,57 +153,7 @@ namespace FreeSql.Tests.Odbc.MySql
{
var sql = g.mysql.CodeFirst.GetComparisonDDLStatements<TableAllType>();
if (string.IsNullOrEmpty(sql) == false)
{
Assert.Equal(@"CREATE TABLE IF NOT EXISTS `cccddd`.`tb_alltype` (
`Id` INT(11) NOT NULL AUTO_INCREMENT,
`testFieldBool` BIT(1) NOT NULL,
`testFieldSByte` TINYINT(3) NOT NULL,
`testFieldShort` SMALLINT(6) NOT NULL,
`testFieldInt` INT(11) NOT NULL,
`testFieldLong` BIGINT(20) NOT NULL,
`testFieldByte` TINYINT(3) UNSIGNED NOT NULL,
`testFieldUShort` SMALLINT(5) UNSIGNED NOT NULL,
`testFieldUInt` INT(10) UNSIGNED NOT NULL,
`testFieldULong` BIGINT(20) UNSIGNED NOT NULL,
`testFieldDouble` DOUBLE NOT NULL,
`testFieldFloat` FLOAT NOT NULL,
`testFieldDecimal` DECIMAL(10,2) NOT NULL,
`testFieldTimeSpan` TIME NOT NULL,
`testFieldDateTime` DATETIME(3) NOT NULL,
`testFieldBytes` VARBINARY(255),
`testFieldString` VARCHAR(255),
`testFieldGuid` VARCHAR(36),
`testFieldBoolNullable` BIT(1),
`testFieldSByteNullable` TINYINT(3),
`testFieldShortNullable` SMALLINT(6),
`testFieldIntNullable` INT(11),
`testFielLongNullable` BIGINT(20),
`testFieldByteNullable` TINYINT(3) UNSIGNED,
`testFieldUShortNullable` SMALLINT(5) UNSIGNED,
`testFieldUIntNullable` INT(10) UNSIGNED,
`testFieldULongNullable` BIGINT(20) UNSIGNED,
`testFieldDoubleNullable` DOUBLE,
`testFieldFloatNullable` FLOAT,
`testFieldDecimalNullable` DECIMAL(10,2),
`testFieldTimeSpanNullable` TIME,
`testFieldDateTimeNullable` DATETIME(3),
`testFieldGuidNullable` VARCHAR(36),
`testFieldPoint` POINT,
`testFieldLineString` LINESTRING,
`testFieldPolygon` POLYGON,
`testFieldMultiPoint` MULTIPOINT,
`testFieldMultiLineString` MULTILINESTRING,
`testFieldMultiPolygon` MULTIPOLYGON,
`testFieldEnum1` ENUM('E1','E2','E3') NOT NULL,
`testFieldEnum1Nullable` ENUM('E1','E2','E3'),
`testFieldEnum2` SET('F1','F2','F3') NOT NULL,
`testFieldEnum2Nullable` SET('F1','F2','F3'),
PRIMARY KEY (`Id`)
) Engine=InnoDB;
", sql);
}
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
sql = g.mysql.CodeFirst.GetComparisonDDLStatements<Tb_alltype>();
}
@ -246,6 +196,7 @@ namespace FreeSql.Tests.Odbc.MySql
testFieldShort = short.MaxValue,
testFieldShortNullable = short.MinValue,
testFieldString = "ÎÒÊÇÖйúÈËstring'\\?!@#$%^&*()_+{}}{~?><<>",
testFieldChar = 'X',
testFieldTimeSpan = TimeSpan.FromSeconds(999),
testFieldTimeSpanNullable = TimeSpan.FromSeconds(60),
testFieldUInt = uint.MaxValue,
@ -265,10 +216,12 @@ namespace FreeSql.Tests.Odbc.MySql
item2.Id = (int)insert.AppendData(item2).ExecuteIdentity();
var newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
item2.Id = (int)insert.NoneParameter().AppendData(item2).ExecuteIdentity();
newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
var items = select.ToList();
var itemstb = select.ToDataTable();
@ -391,6 +344,10 @@ namespace FreeSql.Tests.Odbc.MySql
public string TestFieldString { get; set; }
[JsonProperty, Column(Name = "testFieldChar", DbType = "char(1)", IsNullable = true)]
public char testFieldChar { get; set; }
[JsonProperty, Column(Name = "testFieldTimeSpan", DbType = "time")]
public TimeSpan TestFieldTimeSpan { get; set; }
@ -492,6 +449,7 @@ namespace FreeSql.Tests.Odbc.MySql
public DateTime testFieldDateTime { get; set; }
public byte[] testFieldBytes { get; set; }
public string testFieldString { get; set; }
public char testFieldChar { get; set; }
public Guid testFieldGuid { get; set; }
public bool? testFieldBoolNullable { get; set; }

View File

@ -176,59 +176,8 @@ namespace FreeSql.Tests.Odbc.Oracle
[Fact]
public void GetComparisonDDLStatements()
{
var sql = g.oracle.CodeFirst.GetComparisonDDLStatements<TableAllType>();
if (string.IsNullOrEmpty(sql) == false)
{
Assert.Equal(@"CREATE TABLE IF NOT EXISTS `cccddd`.`tb_alltype` (
`Id` INT(11) NOT NULL AUTO_INCREMENT,
`Bool` BIT(1) NOT NULL,
`SByte` TINYINT(3) NOT NULL,
`Short` SMALLINT(6) NOT NULL,
`Int` INT(11) NOT NULL,
`Long` BIGINT(20) NOT NULL,
`Byte` TINYINT(3) UNSIGNED NOT NULL,
`UShort` SMALLINT(5) UNSIGNED NOT NULL,
`UInt` INT(10) UNSIGNED NOT NULL,
`ULong` BIGINT(20) UNSIGNED NOT NULL,
`Double` DOUBLE NOT NULL,
`Float` FLOAT NOT NULL,
`Decimal` DECIMAL(10,2) NOT NULL,
`TimeSpan` TIME NOT NULL,
`DateTime` DATETIME NOT NULL,
`Bytes` VARBINARY(255),
`String` VARCHAR(255),
`Guid` VARCHAR(36),
`BoolNullable` BIT(1),
`SByteNullable` TINYINT(3),
`ShortNullable` SMALLINT(6),
`IntNullable` INT(11),
`testFielLongNullable` BIGINT(20),
`ByteNullable` TINYINT(3) UNSIGNED,
`UShortNullable` SMALLINT(5) UNSIGNED,
`UIntNullable` INT(10) UNSIGNED,
`ULongNullable` BIGINT(20) UNSIGNED,
`DoubleNullable` DOUBLE,
`FloatNullable` FLOAT,
`DecimalNullable` DECIMAL(10,2),
`TimeSpanNullable` TIME,
`DateTimeNullable` DATETIME,
`GuidNullable` VARCHAR(36),
`Point` POINT,
`LineString` LINESTRING,
`Polygon` POLYGON,
`MultiPoint` MULTIPOINT,
`MultiLineString` MULTILINESTRING,
`MultiPolygon` MULTIPOLYGON,
`Enum1` ENUM('E1','E2','E3') NOT NULL,
`Enum1Nullable` ENUM('E1','E2','E3'),
`Enum2` SET('F1','F2','F3') NOT NULL,
`Enum2Nullable` SET('F1','F2','F3'),
PRIMARY KEY (`Id`)
) Engine=InnoDB;
", sql);
}
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
//sql = g.oracle.CodeFirst.GetComparisonDDLStatements<Tb_alltype>();
}
@ -239,7 +188,17 @@ namespace FreeSql.Tests.Odbc.Oracle
public void CurdAllField()
{
var item = new TableAllType { };
for (var a = 0; a < 100; a++)
{
try //ERROR [23000] [Oracle][ODBC][Ora]ORA-00001: 违反唯一约束条件 (1ODBC.1ODBC_TB_ALLTYPE_pk2)
{
item.Id = (int)insert.AppendData(item).ExecuteIdentity();
break;
}
catch
{
}
}
var newitem = select.Where(a => a.Id == item.Id).ToOne();
@ -271,6 +230,7 @@ namespace FreeSql.Tests.Odbc.Oracle
Short = short.MaxValue,
ShortNullable = short.MinValue,
String = "ÎÒÊÇÖйúÈËstring'\\?!@#$%^&*()_+{}}{~?><<>",
Char = 'X',
TimeSpan = TimeSpan.FromSeconds(999),
TimeSpanNullable = TimeSpan.FromSeconds(60),
UInt = uint.MaxValue,
@ -288,10 +248,12 @@ namespace FreeSql.Tests.Odbc.Oracle
item2.Id = (int)insert.AppendData(item2).ExecuteIdentity();
var newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.String, newitem2.String);
Assert.Equal(item2.Char, newitem2.Char);
item2.Id = (int)insert.NoneParameter().AppendData(item2).ExecuteIdentity();
newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.String, newitem2.String);
Assert.Equal(item2.Char, newitem2.Char);
var items = select.ToList();
var itemstb = select.ToDataTable();
@ -322,6 +284,7 @@ namespace FreeSql.Tests.Odbc.Oracle
public DateTime DateTimeOffSet { get; set; }
public byte[] Bytes { get; set; }
public string String { get; set; }
public char Char { get; set; }
public Guid Guid { get; set; }
public bool? BoolNullable { get; set; }

View File

@ -105,8 +105,8 @@ namespace FreeSql.Tests.Odbc.PostgreSQL
public void AddField()
{
var sql = g.pgsql.CodeFirst.GetComparisonDDLStatements<TopicAddField>();
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
g.pgsql.Select<TopicAddField>();
var id = g.pgsql.Insert<TopicAddField>().AppendData(new TopicAddField { }).ExecuteIdentity();
}
@ -184,6 +184,7 @@ namespace FreeSql.Tests.Odbc.PostgreSQL
testFieldShort = short.MaxValue,
testFieldShortNullable = short.MinValue,
testFieldString = "ÎÒÊÇÖйúÈËstring'\\?!@#$%^&*()_+{}}{~?><<>",
testFieldChar = 'X',
testFieldTimeSpan = TimeSpan.FromDays(1),
testFieldTimeSpanNullable = TimeSpan.FromSeconds(90),
testFieldUInt = uint.MaxValue,
@ -202,10 +203,12 @@ namespace FreeSql.Tests.Odbc.PostgreSQL
var item3 = insert.AppendData(item2).ExecuteInserted().First();
var newitem2 = select.Where(a => a.Id == item3.Id).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
item3 = insert.NoneParameter().AppendData(item2).ExecuteInserted().First();
newitem2 = select.Where(a => a.Id == item3.Id).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
var items = select.ToList();
var itemstb = select.ToDataTable();
@ -233,6 +236,7 @@ namespace FreeSql.Tests.Odbc.PostgreSQL
public DateTime testFieldDateTime { get; set; }
public byte[] testFieldBytes { get; set; }
public string testFieldString { get; set; }
public char testFieldChar { get; set; }
public Guid testFieldGuid { get; set; }
public bool? testFieldBoolNullable { get; set; }

View File

@ -166,9 +166,8 @@ namespace FreeSql.Tests.Odbc.SqlServer
[Fact]
public void GetComparisonDDLStatements()
{
var sql = g.sqlserver.CodeFirst.GetComparisonDDLStatements<TableAllType>();
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
sql = g.sqlserver.CodeFirst.GetComparisonDDLStatements<Tb_alltype>();
}
@ -214,6 +213,7 @@ namespace FreeSql.Tests.Odbc.SqlServer
testFieldShort = short.MaxValue,
testFieldShortNullable = short.MinValue,
testFieldString = "ÎÒÊÇÖйúÈËstring'\\?!@#$%^&*()_+{}}{~?><<>",
testFieldChar = 'X',
testFieldTimeSpan = TimeSpan.FromSeconds(999),
testFieldTimeSpanNullable = TimeSpan.FromSeconds(30),
testFieldUInt = uint.MaxValue,
@ -234,10 +234,12 @@ namespace FreeSql.Tests.Odbc.SqlServer
var item3 = insert.AppendData(item2).ExecuteInserted();
var newitem2 = select.Where(a => a.Id == item3[0].Id).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
item3 = insert.NoneParameter().AppendData(item2).ExecuteInserted();
newitem2 = select.Where(a => a.Id == item3[0].Id).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
var items = select.ToList();
var itemstb = select.ToDataTable();
@ -367,6 +369,10 @@ namespace FreeSql.Tests.Odbc.SqlServer
public string TestFieldString { get; set; }
[JsonProperty, Column(Name = "testFieldChar", DbType = "char(1)", IsNullable = true)]
public char testFieldChar { get; set; }
[JsonProperty, Column(Name = "testFieldTimeSpan", DbType = "time")]
public TimeSpan TestFieldTimeSpan { get; set; }
@ -427,6 +433,7 @@ namespace FreeSql.Tests.Odbc.SqlServer
public DateTimeOffset testFieldDateTimeOffset { get; set; }
public byte[] testFieldBytes { get; set; }
public string testFieldString { get; set; }
public char testFieldChar { get; set; }
public Guid testFieldGuid { get; set; }
public bool? testFieldBoolNullable { get; set; }

View File

@ -22,8 +22,8 @@ namespace FreeSql.Tests.PostgreSQL.NetTopologySuite
[Fact]
public void GetComparisonDDLStatements()
{
var sql = g.pgsql.CodeFirst.GetComparisonDDLStatements<TableAllType>();
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
g.pgsql.Select<TableAllType>();
}
@ -230,6 +230,7 @@ namespace FreeSql.Tests.PostgreSQL.NetTopologySuite
testFieldShortArrayNullable = new short?[] { 1, 2, 3, null, 4, 5 },
testFieldShortNullable = short.MinValue,
testFieldString = "我是中国人string'\\?!@#$%^&*()_+{}}{~?><<>",
testFieldChar = 'X',
testFieldStringArray = new[] { "我是中国人String1", "我是中国人String2", null, "我是中国人String3" },
testFieldTimeSpan = TimeSpan.FromDays(1),
testFieldTimeSpanArray = new[] { TimeSpan.FromDays(1), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(60) },
@ -262,10 +263,12 @@ namespace FreeSql.Tests.PostgreSQL.NetTopologySuite
var item3 = insert.AppendData(item2).ExecuteInserted().First();
var newitem2 = select.Where(a => a.Id == item3.Id && object.Equals(a.testFieldJToken["a"], "1")).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
item3 = insert.NoneParameter().AppendData(item2).ExecuteInserted().First();
newitem2 = select.Where(a => a.Id == item3.Id && object.Equals(a.testFieldJToken["a"], "1")).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
var items = select.ToList();
var itemstb = select.ToDataTable();
@ -296,6 +299,7 @@ namespace FreeSql.Tests.PostgreSQL.NetTopologySuite
public byte[] testFieldBytes { get; set; }
public string testFieldString { get; set; }
public char testFieldChar { get; set; }
public Guid testFieldGuid { get; set; }
public NpgsqlPoint testFieldNpgsqlPoint { get; set; }
public NpgsqlLine testFieldNpgsqlLine { get; set; }

View File

@ -247,59 +247,8 @@ namespace FreeSql.Tests.Dameng
[Fact]
public void GetComparisonDDLStatements()
{
var sql = g.dameng.CodeFirst.GetComparisonDDLStatements<TableAllType>();
if (string.IsNullOrEmpty(sql) == false)
{
Assert.Equal(@"CREATE TABLE IF NOT EXISTS `cccddd`.`tb_alltype` (
`Id` INT(11) NOT NULL AUTO_INCREMENT,
`Bool` BIT(1) NOT NULL,
`SByte` TINYINT(3) NOT NULL,
`Short` SMALLINT(6) NOT NULL,
`Int` INT(11) NOT NULL,
`Long` BIGINT(20) NOT NULL,
`Byte` TINYINT(3) UNSIGNED NOT NULL,
`UShort` SMALLINT(5) UNSIGNED NOT NULL,
`UInt` INT(10) UNSIGNED NOT NULL,
`ULong` BIGINT(20) UNSIGNED NOT NULL,
`Double` DOUBLE NOT NULL,
`Float` FLOAT NOT NULL,
`Decimal` DECIMAL(10,2) NOT NULL,
`TimeSpan` TIME NOT NULL,
`DateTime` DATETIME NOT NULL,
`Bytes` VARBINARY(255),
`String` VARCHAR(255),
`Guid` VARCHAR(36),
`BoolNullable` BIT(1),
`SByteNullable` TINYINT(3),
`ShortNullable` SMALLINT(6),
`IntNullable` INT(11),
`testFielLongNullable` BIGINT(20),
`ByteNullable` TINYINT(3) UNSIGNED,
`UShortNullable` SMALLINT(5) UNSIGNED,
`UIntNullable` INT(10) UNSIGNED,
`ULongNullable` BIGINT(20) UNSIGNED,
`DoubleNullable` DOUBLE,
`FloatNullable` FLOAT,
`DecimalNullable` DECIMAL(10,2),
`TimeSpanNullable` TIME,
`DateTimeNullable` DATETIME,
`GuidNullable` VARCHAR(36),
`Point` POINT,
`LineString` LINESTRING,
`Polygon` POLYGON,
`MultiPoint` MULTIPOINT,
`MultiLineString` MULTILINESTRING,
`MultiPolygon` MULTIPOLYGON,
`Enum1` ENUM('E1','E2','E3') NOT NULL,
`Enum1Nullable` ENUM('E1','E2','E3'),
`Enum2` SET('F1','F2','F3') NOT NULL,
`Enum2Nullable` SET('F1','F2','F3'),
PRIMARY KEY (`Id`)
) Engine=InnoDB;
", sql);
}
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
//sql = g.dameng.CodeFirst.GetComparisonDDLStatements<Tb_alltype>();
}
@ -338,6 +287,7 @@ namespace FreeSql.Tests.Dameng
Short = short.MaxValue,
ShortNullable = short.MinValue,
String = "ÎÒÊÇÖйúÈËstring'\\?!@#$%^&*()_+{}}{~?><<>",
Char = 'X',
TimeSpan = TimeSpan.FromSeconds(999),
TimeSpanNullable = TimeSpan.FromSeconds(60),
UInt = uint.MaxValue,
@ -355,10 +305,12 @@ namespace FreeSql.Tests.Dameng
item2.Id = (int)insert.AppendData(item2).ExecuteIdentity();
var newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.String, newitem2.String);
Assert.Equal(item2.Char, newitem2.Char);
item2.Id = (int)insert.NoneParameter().AppendData(item2).ExecuteIdentity();
newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.String, newitem2.String);
Assert.Equal(item2.Char, newitem2.Char);
var items = select.ToList();
var itemstb = select.ToDataTable();
@ -389,6 +341,7 @@ namespace FreeSql.Tests.Dameng
public DateTime DateTimeOffSet { get; set; }
public byte[] Bytes { get; set; }
public string String { get; set; }
public char Char { get; set; }
public Guid Guid { get; set; }
public bool? BoolNullable { get; set; }

View File

@ -177,54 +177,7 @@ namespace FreeSql.Tests.MsAccess
{
var sql = g.msaccess.CodeFirst.GetComparisonDDLStatements<TableAllType>();
if (string.IsNullOrEmpty(sql) == false)
{
Assert.Equal(@"CREATE TABLE [tb_alltype] (
[Id] AUTOINCREMENT,
[Bool] BIT NOT NULL,
[SByte] DECIMAL(3,0) NOT NULL,
[Short] DECIMAL(6,0) NOT NULL,
[Int] DECIMAL(11,0) NOT NULL,
[Long] DECIMAL(20,0) NOT NULL,
[Byte] DECIMAL(3,0) NOT NULL,
[UShort] DECIMAL(5,0) NOT NULL,
[UInt] DECIMAL(10,0) NOT NULL,
[ULong] DECIMAL(20,0) NOT NULL,
[Double] DOUBLE NOT NULL,
[Float] SINGLE NOT NULL,
[Decimal] DECIMAL(10,2) NOT NULL,
[TimeSpan] TIME NOT NULL,
[DateTime] DATETIME NOT NULL,
[DateTimeOffSet] DATETIME NOT NULL,
[Bytes] BINARY(255),
[String] VARCHAR(255),
[Guid] VARCHAR(36) NOT NULL,
[BoolNullable] BIT,
[SByteNullable] DECIMAL(3,0),
[ShortNullable] DECIMAL(6,0),
[IntNullable] DECIMAL(11,0),
[testFielLongNullable] DECIMAL(20,0),
[ByteNullable] DECIMAL(3,0),
[UShortNullable] DECIMAL(5,0),
[UIntNullable] DECIMAL(10,0),
[ULongNullable] DECIMAL(20,0),
[DoubleNullable] DOUBLE,
[FloatNullable] SINGLE,
[DecimalNullable] DECIMAL(10,2),
[TimeSpanNullable] TIME,
[DateTimeNullable] DATETIME,
[DateTimeOffSetNullable] DATETIME,
[GuidNullable] VARCHAR(36),
[Enum1] DECIMAL(11,0) NOT NULL,
[Enum1Nullable] DECIMAL(11,0),
[Enum2] DECIMAL(20,0) NOT NULL,
[Enum2Nullable] DECIMAL(20,0),
PRIMARY KEY ([Id])
)
;
", sql);
}
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
//sql = g.msaccess.CodeFirst.GetComparisonDDLStatements<Tb_alltype>();
}
@ -267,6 +220,7 @@ namespace FreeSql.Tests.MsAccess
Short = short.MaxValue,
ShortNullable = short.MinValue,
String = "ÎÒÊÇÖйúÈËstring'\\?!@#$%^&*()_+{}}{~?><<>",
Char = 'X',
TimeSpan = TimeSpan.FromSeconds(999),
TimeSpanNullable = TimeSpan.FromSeconds(60),
UInt = uint.MaxValue,
@ -280,10 +234,12 @@ namespace FreeSql.Tests.MsAccess
item2.Id = (int)insert.AppendData(item2).ExecuteIdentity();
var newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.String, newitem2.String);
Assert.Equal(item2.Char, newitem2.Char);
item2.Id = (int)insert.NoneParameter().AppendData(item2).ExecuteIdentity();
newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.String, newitem2.String);
Assert.Equal(item2.Char, newitem2.Char);
var items = select.ToList();
var itemstb = select.ToDataTable();
@ -318,6 +274,7 @@ namespace FreeSql.Tests.MsAccess
public byte[] Bytes { get; set; }
public string String { get; set; }
public char Char { get; set; }
public Guid Guid { get; set; }
public bool? BoolNullable { get; set; }

View File

@ -281,57 +281,7 @@ namespace FreeSql.Tests.MySql
{
var sql = g.mysql.CodeFirst.GetComparisonDDLStatements<TableAllType>();
if (string.IsNullOrEmpty(sql) == false)
{
Assert.Equal(@"CREATE TABLE IF NOT EXISTS `cccddd`.`tb_alltype` (
`Id` INT(11) NOT NULL AUTO_INCREMENT,
`testFieldBool` BIT(1) NOT NULL,
`testFieldSByte` TINYINT(3) NOT NULL,
`testFieldShort` SMALLINT(6) NOT NULL,
`testFieldInt` INT(11) NOT NULL,
`testFieldLong` BIGINT(20) NOT NULL,
`testFieldByte` TINYINT(3) UNSIGNED NOT NULL,
`testFieldUShort` SMALLINT(5) UNSIGNED NOT NULL,
`testFieldUInt` INT(10) UNSIGNED NOT NULL,
`testFieldULong` BIGINT(20) UNSIGNED NOT NULL,
`testFieldDouble` DOUBLE NOT NULL,
`testFieldFloat` FLOAT NOT NULL,
`testFieldDecimal` DECIMAL(10,2) NOT NULL,
`testFieldTimeSpan` TIME NOT NULL,
`testFieldDateTime` DATETIME(3) NOT NULL,
`testFieldBytes` VARBINARY(255),
`testFieldString` VARCHAR(255),
`testFieldGuid` VARCHAR(36),
`testFieldBoolNullable` BIT(1),
`testFieldSByteNullable` TINYINT(3),
`testFieldShortNullable` SMALLINT(6),
`testFieldIntNullable` INT(11),
`testFielLongNullable` BIGINT(20),
`testFieldByteNullable` TINYINT(3) UNSIGNED,
`testFieldUShortNullable` SMALLINT(5) UNSIGNED,
`testFieldUIntNullable` INT(10) UNSIGNED,
`testFieldULongNullable` BIGINT(20) UNSIGNED,
`testFieldDoubleNullable` DOUBLE,
`testFieldFloatNullable` FLOAT,
`testFieldDecimalNullable` DECIMAL(10,2),
`testFieldTimeSpanNullable` TIME,
`testFieldDateTimeNullable` DATETIME(3),
`testFieldGuidNullable` VARCHAR(36),
`testFieldPoint` POINT,
`testFieldLineString` LINESTRING,
`testFieldPolygon` POLYGON,
`testFieldMultiPoint` MULTIPOINT,
`testFieldMultiLineString` MULTILINESTRING,
`testFieldMultiPolygon` MULTIPOLYGON,
`testFieldEnum1` ENUM('E1','E2','E3') NOT NULL,
`testFieldEnum1Nullable` ENUM('E1','E2','E3'),
`testFieldEnum2` SET('F1','F2','F3') NOT NULL,
`testFieldEnum2Nullable` SET('F1','F2','F3'),
PRIMARY KEY (`Id`)
) Engine=InnoDB;
", sql);
}
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
sql = g.mysql.CodeFirst.GetComparisonDDLStatements<Tb_alltype>();
}
@ -397,6 +347,7 @@ namespace FreeSql.Tests.MySql
testFieldShort = short.MaxValue,
testFieldShortNullable = short.MinValue,
testFieldString = "ÎÒÊÇÖйúÈËstring'\\?!@#$%^&*()_+{}}{~?><<>",
testFieldChar = 'X',
testFieldTimeSpan = TimeSpan.FromSeconds(999),
testFieldTimeSpanNullable = TimeSpan.FromSeconds(60),
testFieldUInt = uint.MaxValue,
@ -416,10 +367,12 @@ namespace FreeSql.Tests.MySql
item2.Id = (int)insert.AppendData(item2).ExecuteIdentity();
var newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
item2.Id = (int)insert.NoneParameter().AppendData(item2).ExecuteIdentity();
newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
var items = select.ToList();
var itemstb = select.ToDataTable();
@ -566,6 +519,10 @@ namespace FreeSql.Tests.MySql
public string TestFieldString { get; set; }
[JsonProperty, Column(Name = "testFieldChar", DbType = "char(1)", IsNullable = true)]
public char testFieldChar { get; set; }
[JsonProperty, Column(Name = "testFieldTimeSpan", DbType = "time")]
public TimeSpan TestFieldTimeSpan { get; set; }
@ -670,6 +627,7 @@ namespace FreeSql.Tests.MySql
public byte[] testFieldBytes { get; set; }
public string testFieldString { get; set; }
public char testFieldChar { get; set; }
public Guid testFieldGuid { get; set; }
public bool? testFieldBoolNullable { get; set; }

View File

@ -279,57 +279,7 @@ namespace FreeSql.Tests.Oracle
{
var sql = g.oracle.CodeFirst.GetComparisonDDLStatements<TableAllType>();
if (string.IsNullOrEmpty(sql) == false)
{
Assert.Equal(@"CREATE TABLE IF NOT EXISTS `cccddd`.`tb_alltype` (
`Id` INT(11) NOT NULL AUTO_INCREMENT,
`Bool` BIT(1) NOT NULL,
`SByte` TINYINT(3) NOT NULL,
`Short` SMALLINT(6) NOT NULL,
`Int` INT(11) NOT NULL,
`Long` BIGINT(20) NOT NULL,
`Byte` TINYINT(3) UNSIGNED NOT NULL,
`UShort` SMALLINT(5) UNSIGNED NOT NULL,
`UInt` INT(10) UNSIGNED NOT NULL,
`ULong` BIGINT(20) UNSIGNED NOT NULL,
`Double` DOUBLE NOT NULL,
`Float` FLOAT NOT NULL,
`Decimal` DECIMAL(10,2) NOT NULL,
`TimeSpan` TIME NOT NULL,
`DateTime` DATETIME NOT NULL,
`Bytes` VARBINARY(255),
`String` VARCHAR(255),
`Guid` VARCHAR(36),
`BoolNullable` BIT(1),
`SByteNullable` TINYINT(3),
`ShortNullable` SMALLINT(6),
`IntNullable` INT(11),
`testFielLongNullable` BIGINT(20),
`ByteNullable` TINYINT(3) UNSIGNED,
`UShortNullable` SMALLINT(5) UNSIGNED,
`UIntNullable` INT(10) UNSIGNED,
`ULongNullable` BIGINT(20) UNSIGNED,
`DoubleNullable` DOUBLE,
`FloatNullable` FLOAT,
`DecimalNullable` DECIMAL(10,2),
`TimeSpanNullable` TIME,
`DateTimeNullable` DATETIME,
`GuidNullable` VARCHAR(36),
`Point` POINT,
`LineString` LINESTRING,
`Polygon` POLYGON,
`MultiPoint` MULTIPOINT,
`MultiLineString` MULTILINESTRING,
`MultiPolygon` MULTIPOLYGON,
`Enum1` ENUM('E1','E2','E3') NOT NULL,
`Enum1Nullable` ENUM('E1','E2','E3'),
`Enum2` SET('F1','F2','F3') NOT NULL,
`Enum2Nullable` SET('F1','F2','F3'),
PRIMARY KEY (`Id`)
) Engine=InnoDB;
", sql);
}
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
//sql = g.oracle.CodeFirst.GetComparisonDDLStatements<Tb_alltype>();
}
@ -372,6 +322,7 @@ namespace FreeSql.Tests.Oracle
Short = short.MaxValue,
ShortNullable = short.MinValue,
String = "ÎÒÊÇÖйúÈËstring'\\?!@#$%^&*()_+{}}{~?><<>",
Char = 'X',
TimeSpan = TimeSpan.FromSeconds(999),
TimeSpanNullable = TimeSpan.FromSeconds(60),
UInt = uint.MaxValue,
@ -389,10 +340,12 @@ namespace FreeSql.Tests.Oracle
item2.Id = (int)insert.AppendData(item2).ExecuteIdentity();
var newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.String, newitem2.String);
Assert.Equal(item2.Char, newitem2.Char);
item2.Id = (int)insert.NoneParameter().AppendData(item2).ExecuteIdentity();
newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.String, newitem2.String);
Assert.Equal(item2.Char, newitem2.Char);
var items = select.ToList();
var itemstb = select.ToDataTable();
@ -427,6 +380,7 @@ namespace FreeSql.Tests.Oracle
public byte[] Bytes { get; set; }
public string String { get; set; }
public char Char { get; set; }
public Guid Guid { get; set; }
public bool? BoolNullable { get; set; }

View File

@ -145,8 +145,8 @@ namespace FreeSql.Tests.PostgreSQL
public void AddField()
{
var sql = g.pgsql.CodeFirst.GetComparisonDDLStatements<TopicAddField>();
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
g.pgsql.Select<TopicAddField>();
var id = g.pgsql.Insert<TopicAddField>().AppendData(new TopicAddField { }).ExecuteIdentity();
}
@ -388,6 +388,7 @@ namespace FreeSql.Tests.PostgreSQL
testFieldShortArrayNullable = new short?[] { 1, 2, 3, null, 4, 5 },
testFieldShortNullable = short.MinValue,
testFieldString = "我是中国人string'\\?!@#$%^&*()_+{}}{~?><<>",
testFieldChar = 'X',
testFieldStringArray = new[] { "我是中国人String1", "我是中国人String2", null, "我是中国人String3" },
testFieldTimeSpan = TimeSpan.FromDays(1),
testFieldTimeSpanArray = new[] { TimeSpan.FromDays(1), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(60) },
@ -420,10 +421,12 @@ namespace FreeSql.Tests.PostgreSQL
var item3 = insert.AppendData(item2).ExecuteInserted().First();
var newitem2 = select.Where(a => a.Id == item3.Id && object.Equals(a.testFieldJToken["a"], "1")).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
item3 = insert.NoneParameter().AppendData(item2).ExecuteInserted().First();
newitem2 = select.Where(a => a.Id == item3.Id && object.Equals(a.testFieldJToken["a"], "1")).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
var items = select.ToList();
var itemstb = select.ToDataTable();
@ -454,6 +457,7 @@ namespace FreeSql.Tests.PostgreSQL
public byte[] testFieldBytes { get; set; }
public string testFieldString { get; set; }
public char testFieldChar { get; set; }
public Guid testFieldGuid { get; set; }
public NpgsqlPoint testFieldNpgsqlPoint { get; set; }
public NpgsqlLine testFieldNpgsqlLine { get; set; }

View File

@ -143,8 +143,8 @@ namespace FreeSql.Tests.ShenTong
[Fact]
public void GetComparisonDDLStatements()
{
var sql = g.shentong.CodeFirst.GetComparisonDDLStatements<TableAllType>();
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
g.shentong.Select<TableAllType>();
}
@ -217,6 +217,7 @@ namespace FreeSql.Tests.ShenTong
//testFieldShortArrayNullable = new short?[] { 1, 2, 3, null, 4, 5 },
testFieldShortNullable = short.MinValue,
testFieldString = "我是中国人string'\\?!@#$%^&*()_+{}}{~?><<>",
testFieldChar = 'X',
//testFieldStringArray = new[] { "我是中国人String1", "我是中国人String2", null, "我是中国人String3" },
testFieldTimeSpan = TimeSpan.FromHours(10),
//testFieldTimeSpanArray = new[] { TimeSpan.FromHours(10), TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(60) },
@ -245,10 +246,12 @@ namespace FreeSql.Tests.ShenTong
var item3 = insert.AppendData(item2).ExecuteInserted().First();
var newitem2 = select.Where(a => a.Id == item3.Id).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
item3 = insert.NoneParameter().AppendData(item2).ExecuteInserted().First();
newitem2 = select.Where(a => a.Id == item3.Id).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
var items = select.ToList();
var itemstb = select.ToDataTable();
@ -279,6 +282,7 @@ namespace FreeSql.Tests.ShenTong
public byte[] testFieldBytes { get; set; }
public string testFieldString { get; set; }
public char testFieldChar { get; set; }
public Guid testFieldGuid { get; set; }
public bool? testFieldBoolNullable { get; set; }

View File

@ -202,9 +202,8 @@ namespace FreeSql.Tests.SqlServer
[Fact]
public void GetComparisonDDLStatements()
{
var sql = g.sqlserver.CodeFirst.GetComparisonDDLStatements<TableAllType>();
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
sql = g.sqlserver.CodeFirst.GetComparisonDDLStatements<Tb_alltype>();
}
@ -250,6 +249,7 @@ namespace FreeSql.Tests.SqlServer
testFieldShort = short.MaxValue,
testFieldShortNullable = short.MinValue,
testFieldString = "ÎÒÊÇÖйúÈËstring'\\?!@#$%^&*()_+{}}{~?><<>",
testFieldChar = 'X',
testFieldTimeSpan = TimeSpan.FromSeconds(999),
testFieldTimeSpanNullable = TimeSpan.FromSeconds(30),
testFieldUInt = uint.MaxValue,
@ -270,10 +270,12 @@ namespace FreeSql.Tests.SqlServer
var item3 = insert.AppendData(item2).ExecuteInserted();
var newitem2 = select.Where(a => a.Id == item3[0].Id).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
item3 = insert.NoneParameter().AppendData(item2).ExecuteInserted();
newitem2 = select.Where(a => a.Id == item3[0].Id).ToOne();
Assert.Equal(item2.testFieldString, newitem2.testFieldString);
Assert.Equal(item2.testFieldChar, newitem2.testFieldChar);
var items = select.ToList();
var itemstb = select.ToDataTable();
@ -403,6 +405,10 @@ namespace FreeSql.Tests.SqlServer
public string TestFieldString { get; set; }
[JsonProperty, Column(Name = "testFieldChar", DbType = "char(1)", IsNullable = true)]
public char testFieldChar { get; set; }
[JsonProperty, Column(Name = "testFieldTimeSpan", DbType = "time")]
public TimeSpan TestFieldTimeSpan { get; set; }
@ -467,6 +473,7 @@ namespace FreeSql.Tests.SqlServer
public byte[] testFieldBytes { get; set; }
public string testFieldString { get; set; }
public char testFieldChar { get; set; }
public Guid testFieldGuid { get; set; }
public bool? testFieldBoolNullable { get; set; }

View File

@ -239,53 +239,7 @@ namespace FreeSql.Tests.Sqlite
{
var sql = g.sqlite.CodeFirst.GetComparisonDDLStatements<TableAllType>();
if (string.IsNullOrEmpty(sql) == false)
{
Assert.Equal(@"CREATE TABLE IF NOT EXISTS ""main"".""tb_alltype"" (
""Id"" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
""Bool"" BOOLEAN NOT NULL,
""SByte"" SMALLINT NOT NULL,
""Short"" SMALLINT NOT NULL,
""Int"" INTEGER NOT NULL,
""Long"" INTEGER NOT NULL,
""Byte"" INT2 NOT NULL,
""UShort"" UNSIGNED NOT NULL,
""UInt"" DECIMAL(10,0) NOT NULL,
""ULong"" DECIMAL(21,0) NOT NULL,
""Double"" DOUBLE NOT NULL,
""Float"" FLOAT NOT NULL,
""Decimal"" DECIMAL(10,2) NOT NULL,
""TimeSpan"" BIGINT NOT NULL,
""DateTime"" DATETIME NOT NULL,
""DateTimeOffSet"" DATETIME NOT NULL,
""Bytes"" BLOB,
""String"" NVARCHAR(255),
""Guid"" CHARACTER(36) NOT NULL,
""BoolNullable"" BOOLEAN,
""SByteNullable"" SMALLINT,
""ShortNullable"" SMALLINT,
""IntNullable"" INTEGER,
""testFielLongNullable"" INTEGER,
""ByteNullable"" INT2,
""UShortNullable"" UNSIGNED,
""UIntNullable"" DECIMAL(10,0),
""ULongNullable"" DECIMAL(21,0),
""DoubleNullable"" DOUBLE,
""FloatNullable"" FLOAT,
""DecimalNullable"" DECIMAL(10,2),
""TimeSpanNullable"" BIGINT,
""DateTimeNullable"" DATETIME,
""DateTimeOffSetNullable"" DATETIME,
""GuidNullable"" CHARACTER(36),
""Enum1"" MEDIUMINT NOT NULL,
""Enum1Nullable"" MEDIUMINT,
""Enum2"" BIGINT NOT NULL,
""Enum2Nullable"" BIGINT
)
;
", sql);
}
Assert.True(string.IsNullOrEmpty(sql)); //测试运行两次后
//sql = g.Sqlite.CodeFirst.GetComparisonDDLStatements<Tb_alltype>();
}
@ -328,6 +282,7 @@ namespace FreeSql.Tests.Sqlite
Short = short.MaxValue,
ShortNullable = short.MinValue,
String = "ÎÒÊÇÖйúÈËstring'\\?!@#$%^&*()_+{}}{~?><<>",
Char = 'X',
TimeSpan = TimeSpan.FromSeconds(999),
TimeSpanNullable = TimeSpan.FromSeconds(60),
UInt = uint.MaxValue,
@ -341,10 +296,12 @@ namespace FreeSql.Tests.Sqlite
item2.Id = (int)insert.AppendData(item2).ExecuteIdentity();
var newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.String, newitem2.String);
Assert.Equal(item2.Char, newitem2.Char);
item2.Id = (int)insert.NoneParameter().AppendData(item2).ExecuteIdentity();
newitem2 = select.Where(a => a.Id == item2.Id).ToOne();
Assert.Equal(item2.String, newitem2.String);
Assert.Equal(item2.Char, newitem2.Char);
var items = select.ToList();
var itemstb = select.ToDataTable();
@ -379,6 +336,7 @@ namespace FreeSql.Tests.Sqlite
public byte[] Bytes { get; set; }
public string String { get; set; }
public char Char { get; set; }
public Guid Guid { get; set; }
public bool? BoolNullable { get; set; }

View File

@ -451,6 +451,7 @@ namespace FreeSql.Internal
var m = Regex.Match(col.Attribute.DbType, ltp);
if (m.Success == false) continue;
var sizeStr = m.Groups[1].Value.Trim();
if (sizeStr.EndsWith(" BYTE") || sizeStr.EndsWith(" CHAR")) sizeStr = sizeStr.Remove(sizeStr.Length - 5); //ORACLE
if (string.Compare(sizeStr, "max", true) == 0)
{
col.DbSize = -1;
@ -1257,6 +1258,7 @@ namespace FreeSql.Internal
[typeof(DateTimeOffset)] = true,
[typeof(byte[])] = true,
[typeof(string)] = true,
[typeof(char)] = true,
[typeof(Guid)] = true,
//[typeof(MygisPoint)] = true,
//[typeof(MygisLineString)] = true,
@ -1719,6 +1721,11 @@ namespace FreeSql.Internal
if (bytes == null) return Guid.Empty;
return Guid.TryParse(BitConverter.ToString(bytes, 0, Math.Min(bytes.Length, 36)).Replace("-", ""), out var tryguid) ? tryguid : Guid.Empty;
}
static char StringToChar(string str)
{
if (string.IsNullOrEmpty(str)) return default(char);
return str.ToCharArray(0, 1)[0];
}
static ConcurrentDictionary<Type, ConcurrentDictionary<Type, Func<object, object>>> _dicGetDataReaderValue = new ConcurrentDictionary<Type, ConcurrentDictionary<Type, Func<object, object>>>();
static MethodInfo MethodArrayGetValue = typeof(Array).GetMethod("GetValue", new[] { typeof(int) });
@ -1749,6 +1756,8 @@ namespace FreeSql.Internal
static Encoding DefaultEncoding = Encoding.UTF8;
static MethodInfo MethodEncodingGetBytes = typeof(Encoding).GetMethod("GetBytes", new[] { typeof(string) });
static MethodInfo MethodEncodingGetString = typeof(Encoding).GetMethod("GetString", new[] { typeof(byte[]) });
static MethodInfo MethodStringToCharArray = typeof(string).GetMethod("ToCharArray", new Type[0]);
static MethodInfo MethodStringToChar = typeof(Utils).GetMethod("StringToChar", BindingFlags.NonPublic | BindingFlags.Static, null, new[] { typeof(string) }, null);
static MethodInfo MethodGuidToBytes = typeof(Utils).GetMethod("GuidToBytes", BindingFlags.NonPublic | BindingFlags.Static, null, new[] { typeof(Guid) }, null);
static MethodInfo MethodBytesToGuid = typeof(Utils).GetMethod("BytesToGuid", BindingFlags.NonPublic | BindingFlags.Static, null, new[] { typeof(byte[]) }, null);
@ -1760,7 +1769,12 @@ namespace FreeSql.Internal
var valueExp = Expression.Variable(typeof(object), "locvalue");
Func<Expression> funcGetExpression = () =>
{
if (type.FullName == "System.Byte[]") return Expression.IfThenElse(
if (type.IsArray)
{
switch (type.FullName)
{
case "System.Byte[]":
return Expression.IfThenElse(
Expression.TypeEqual(valueExp, type),
Expression.Return(returnTarget, valueExp),
Expression.IfThenElse(
@ -1773,8 +1787,17 @@ namespace FreeSql.Internal
)
)
);
if (type.IsArray)
{
case "System.Char[]":
return Expression.IfThenElse(
Expression.TypeEqual(valueExp, type),
Expression.Return(returnTarget, valueExp),
Expression.IfThenElse(
Expression.TypeEqual(valueExp, typeof(string)),
Expression.Return(returnTarget, Expression.Call(Expression.Convert(valueExp, typeof(string)), MethodStringToCharArray)),
Expression.Return(returnTarget, Expression.Call(Expression.Call(MethodToString, valueExp), MethodStringToCharArray))
)
);
}
var elementType = type.GetElementType();
var arrNewExp = Expression.Variable(type, "arrNew");
var arrExp = Expression.Variable(typeof(Array), "arr");
@ -1817,14 +1840,6 @@ namespace FreeSql.Internal
}
var typeOrg = type;
if (type.IsNullableType()) type = type.GetGenericArguments().First();
if (type.IsEnum)
return Expression.Block(
Expression.IfThenElse(
Expression.Equal(Expression.TypeAs(valueExp, typeof(string)), Expression.Constant(string.Empty)),
Expression.Return(returnTarget, Expression.Convert(Expression.Default(type), typeof(object))),
Expression.Return(returnTarget, Expression.Call(MethodEnumParse, Expression.Constant(type, typeof(Type)), Expression.Call(MethodToString, valueExp), Expression.Constant(true, typeof(bool))))
)
);
Expression tryparseExp = null;
Expression tryparseBooleanExp = null;
ParameterExpression tryparseVarExp = null;
@ -1860,6 +1875,16 @@ namespace FreeSql.Internal
)
}
);
case "System.Char":
return Expression.IfThenElse(
Expression.TypeEqual(valueExp, type),
Expression.Return(returnTarget, valueExp),
Expression.IfThenElse(
Expression.TypeEqual(valueExp, typeof(string)),
Expression.Return(returnTarget, Expression.Convert(Expression.Call(MethodStringToChar, Expression.Convert(valueExp, typeof(string))), typeof(object))),
Expression.Return(returnTarget, Expression.Convert(Expression.Call(MethodStringToChar, Expression.Call(MethodToString, valueExp)), typeof(object)))
)
);
case "System.SByte":
tryparseExp = Expression.Block(
new[] { tryparseVarExp = Expression.Variable(typeof(sbyte)) },
@ -2029,6 +2054,14 @@ namespace FreeSql.Internal
);
break;
default:
if (type.IsEnum)
return Expression.Block(
Expression.IfThenElse(
Expression.Equal(Expression.TypeAs(valueExp, typeof(string)), Expression.Constant(string.Empty)),
Expression.Return(returnTarget, Expression.Convert(Expression.Default(type), typeof(object))),
Expression.Return(returnTarget, Expression.Call(MethodEnumParse, Expression.Constant(type, typeof(Type)), Expression.Call(MethodToString, valueExp), Expression.Constant(true, typeof(bool))))
)
);
foreach (var switchFunc in GetDataReaderValueBlockExpressionSwitchTypeFullName)
{
var switchFuncRet = switchFunc(returnTarget, valueExp, type);

View File

@ -41,8 +41,10 @@ namespace FreeSql.Dameng
return $"hextoraw('{CommonUtils.BytesSqlRaw(param as byte[])}')";
else if (param is bool || param is bool?)
return (bool)param ? 1 : 0;
else if (param is string || param is char)
else if (param is string)
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
else if (param is char)
return string.Concat("'", param.ToString().Replace("'", "''").Replace('\0', ' '), "'");
else if (param is Enum)
return ((Enum)param).ToInt64();
else if (decimal.TryParse(string.Concat(param), out var trydec))

View File

@ -42,6 +42,7 @@ namespace FreeSql.Dameng
{ typeof(byte[]).FullName, CsToDb.New(DmDbType.VarBinary, "blob", "blob NULL", false, null, new byte[0]) },
{ typeof(string).FullName, CsToDb.New(DmDbType.VarChar, "nvarchar2", "nvarchar2(255) NULL", false, null, "") },
{ typeof(char).FullName, CsToDb.New(DmDbType.Char, "char", "char(1) NULL", false, null, '\0') },
{ typeof(Guid).FullName, CsToDb.New(DmDbType.Char, "char", "char(36) NOT NULL", false, false, Guid.Empty) },{ typeof(Guid?).FullName, CsToDb.New(DmDbType.Char, "char", "char(36) NULL", false, true, null) },
};

View File

@ -42,8 +42,10 @@ namespace FreeSql.MsAccess
if (param is bool || param is bool?)
return (bool)param ? -1 : 0;
else if (param is string || param is char)
else if (param is string)
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
else if (param is char)
return string.Concat("'", param.ToString().Replace("'", "''").Replace('\0', ' '), "'");
else if (param is Enum)
return ((Enum)param).ToInt64();
else if (decimal.TryParse(string.Concat(param), out var trydec))

View File

@ -39,6 +39,7 @@ namespace FreeSql.MsAccess
{ typeof(byte[]).FullName, CsToDb.New(OleDbType.VarBinary, "varbinary", "varbinary(255)", false, null, new byte[0]) },
{ typeof(string).FullName, CsToDb.New(OleDbType.VarChar, "varchar", "varchar(255)", false, null, "") },
{ typeof(char).FullName, CsToDb.New(OleDbType.VarChar, "varchar", "varchar(1)", false, null, '\0') },
{ typeof(Guid).FullName, CsToDb.New(OleDbType.Guid, "varchar", "varchar(36) NOT NULL", false, false, Guid.Empty) },{ typeof(Guid?).FullName, CsToDb.New(OleDbType.Guid, "varchar", "varchar(36)", false, true, null) },
};

View File

@ -45,8 +45,10 @@ namespace FreeSql.MySql
if (param is bool || param is bool?)
return (bool)param ? 1 : 0;
else if (param is string || param is char)
else if (param is string)
return string.Concat("'", param.ToString().Replace("'", "''").Replace("\\", "\\\\"), "'"); //只有 mysql 需要处理反斜杠
else if (param is char)
return string.Concat("'", param.ToString().Replace("'", "''").Replace("\\", "\\\\").Replace('\0', ' '), "'");
else if (param is Enum)
return string.Concat("'", param.ToString().Replace("'", "''").Replace("\\", "\\\\"), "'"); //((Enum)val).ToInt64();
else if (decimal.TryParse(string.Concat(param), out var trydec))

View File

@ -45,6 +45,7 @@ namespace FreeSql.MySql
{ typeof(byte[]).FullName, CsToDb.New(MySqlDbType.VarBinary, "varbinary", "varbinary(255)", false, null, new byte[0]) },
{ typeof(string).FullName, CsToDb.New(MySqlDbType.VarChar, "varchar", "varchar(255)", false, null, "") },
{ typeof(char).FullName, CsToDb.New(MySqlDbType.VarChar, "char", "char(1)", false, null, '\0') },
{ typeof(Guid).FullName, CsToDb.New(MySqlDbType.VarChar, "char", "char(36) NOT NULL", false, false, Guid.Empty) },{ typeof(Guid?).FullName, CsToDb.New(MySqlDbType.VarChar, "char", "char(36)", false, true, null) },

View File

@ -42,8 +42,10 @@ namespace FreeSql.Odbc.Dameng
return $"hextoraw('{CommonUtils.BytesSqlRaw(param as byte[])}')";
else if (param is bool || param is bool?)
return (bool)param ? 1 : 0;
else if (param is string || param is char)
else if (param is string)
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
else if (param is char)
return string.Concat("'", param.ToString().Replace("'", "''").Replace('\0', ' '), "'");
else if (param is Enum)
return ((Enum)param).ToInt64();
else if (decimal.TryParse(string.Concat(param), out var trydec))

View File

@ -43,6 +43,7 @@ namespace FreeSql.Odbc.Dameng
{ typeof(byte[]).FullName, CsToDb.New(OdbcType.VarBinary, "blob", "blob NULL", false, null, new byte[0]) },
{ typeof(string).FullName, CsToDb.New(OdbcType.NVarChar, "nvarchar2", "nvarchar2(255) NULL", false, null, "") },
{ typeof(char).FullName, CsToDb.New(OdbcType.Char, "char", "char(1) NULL", false, null, '\0') },
{ typeof(Guid).FullName, CsToDb.New(OdbcType.Char, "char", "char(36) NOT NULL", false, false, Guid.Empty) },{ typeof(Guid?).FullName, CsToDb.New(OdbcType.Char, "char", "char(36) NULL", false, true, null) },
};

View File

@ -38,6 +38,7 @@ namespace FreeSql.Odbc.Default
public virtual string MappingOdbcTypeDateTime => "datetime";
public virtual string MappingOdbcTypeVarBinary => "varbinary";
public virtual string MappingOdbcTypeVarChar => "nvarchar";
public virtual string MappingOdbcTypeChar => "char";
public virtual string MappingOdbcTypeText => "nvarchar(max)";
public virtual string MappingOdbcTypeUniqueIdentifier => "uniqueidentifier";

View File

@ -45,7 +45,7 @@ namespace FreeSql.Odbc.Default
else if (param is string)
return Adapter.UnicodeStringRawSql(param, mapColumn);
else if (param is char)
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
return string.Concat("'", param.ToString().Replace("'", "''").Replace('\0', ' '), "'");
else if (param is Enum)
return ((Enum)param).ToInt64();
else if (decimal.TryParse(string.Concat(param), out var trydec))

View File

@ -56,6 +56,7 @@ namespace FreeSql.Odbc.Default
{ typeof(byte[]).FullName, CsToDb.New(OdbcType.VarBinary, _utils.Adapter.MappingOdbcTypeVarBinary, $"{_utils.Adapter.MappingOdbcTypeVarBinary}(255)", false, null, new byte[0]) },
{ typeof(string).FullName, CsToDb.New(OdbcType.VarChar, _utils.Adapter.MappingOdbcTypeVarChar, $"{_utils.Adapter.MappingOdbcTypeVarChar}(255)", false, null, "") },
{ typeof(char).FullName, CsToDb.New(OdbcType.Char, _utils.Adapter.MappingOdbcTypeChar, $"{_utils.Adapter.MappingOdbcTypeChar}(1)", false, null, '\0') },
{ typeof(Guid).FullName, CsToDb.New(OdbcType.UniqueIdentifier, deleteBrackets(_utils.Adapter.MappingOdbcTypeUniqueIdentifier), $"{_utils.Adapter.MappingOdbcTypeUniqueIdentifier} NOT NULL", false, false, Guid.Empty) },{ typeof(Guid?).FullName, CsToDb.New(OdbcType.UniqueIdentifier, deleteBrackets(_utils.Adapter.MappingOdbcTypeUniqueIdentifier), _utils.Adapter.MappingOdbcTypeUniqueIdentifier, false, true, null) },
};

View File

@ -41,8 +41,10 @@ namespace FreeSql.Odbc.KingbaseES
if (param is bool || param is bool?)
return (bool)param ? "'t'" : "'f'";
else if (param is string || param is char)
else if (param is string)
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
else if (param is char)
return string.Concat("'", param.ToString().Replace("'", "''").Replace('\0', ' '), "'");
else if (param is Enum)
return ((Enum)param).ToInt64();
else if (decimal.TryParse(string.Concat(param), out var trydec))

View File

@ -35,6 +35,7 @@ namespace FreeSql.Odbc.KingbaseES
{ typeof(decimal).FullName, CsToDb.New(OdbcType.Numeric, "numeric", "numeric(10,2) NOT NULL", false, false, 0) },{ typeof(decimal?).FullName, CsToDb.New(OdbcType.Numeric, "numeric", "numeric(10,2)", false, true, null) },
{ typeof(string).FullName, CsToDb.New(OdbcType.VarChar, "varchar", "varchar(255)", false, null, "") },
{ typeof(char).FullName, CsToDb.New(OdbcType.Char, "bpchar", "bpchar(1) NULL", false, null, '\0') },
{ typeof(TimeSpan).FullName, CsToDb.New(OdbcType.Time, "time","time NOT NULL", false, false, 0) },{ typeof(TimeSpan?).FullName, CsToDb.New(OdbcType.Time, "time", "time",false, true, null) },
{ typeof(DateTime).FullName, CsToDb.New(OdbcType.DateTime, "timestamp", "timestamp NOT NULL", false, false, new DateTime(1970,1,1)) },{ typeof(DateTime?).FullName, CsToDb.New(OdbcType.DateTime, "timestamp", "timestamp", false, true, null) },

View File

@ -35,6 +35,7 @@ namespace FreeSql.Odbc.KingbaseES
{ typeof(ushort).FullName, a => int.Parse(string.Concat(a)) }, { typeof(ushort[]).FullName, a => getParamterArrayValue(typeof(int), a, 0) }, { typeof(ushort?[]).FullName, a => getParamterArrayValue(typeof(int?), a, null) },
{ typeof(byte).FullName, a => short.Parse(string.Concat(a)) }, { typeof(byte[]).FullName, a => getParamterArrayValue(typeof(short), a, 0) }, { typeof(byte?[]).FullName, a => getParamterArrayValue(typeof(short?), a, null) },
{ typeof(sbyte).FullName, a => short.Parse(string.Concat(a)) }, { typeof(sbyte[]).FullName, a => getParamterArrayValue(typeof(short), a, 0) }, { typeof(sbyte?[]).FullName, a => getParamterArrayValue(typeof(short?), a, null) },
{ typeof(char).FullName, a => string.Concat(a).Replace('\0', ' ').ToCharArray().FirstOrDefault() },
};
static object getParamterValue(Type type, object value, int level = 0)
{

View File

@ -41,8 +41,10 @@ namespace FreeSql.Odbc.MySql
if (param is bool || param is bool?)
return (bool)param ? 1 : 0;
else if (param is string || param is char)
else if (param is string)
return string.Concat("'", param.ToString().Replace("'", "''").Replace("\\", "\\\\"), "'"); //只有 mysql 需要处理反斜杠
else if (param is char)
return string.Concat("'", param.ToString().Replace("'", "''").Replace("\\", "\\\\").Replace('\0', ' '), "'");
else if (param is Enum)
return string.Concat("'", param.ToString().Replace("'", "''").Replace("\\", "\\\\"), "'"); //((Enum)val).ToInt64();
else if (decimal.TryParse(string.Concat(param), out var trydec))

View File

@ -41,6 +41,7 @@ namespace FreeSql.Odbc.MySql
{ typeof(byte[]).FullName, CsToDb.New(OdbcType.VarBinary, "varbinary", "varbinary(255)", false, null, new byte[0]) },
{ typeof(string).FullName, CsToDb.New(OdbcType.VarChar, "varchar", "varchar(255)", false, null, "") },
{ typeof(char).FullName, CsToDb.New(OdbcType.Char, "char", "char(1) NULL", false, null, '\0') },
{ typeof(Guid).FullName, CsToDb.New(OdbcType.VarChar, "char", "char(36) NOT NULL", false, false, Guid.Empty) },{ typeof(Guid?).FullName, CsToDb.New(OdbcType.VarChar, "char", "char(36)", false, true, null) },
};

View File

@ -42,8 +42,10 @@ namespace FreeSql.Odbc.Oracle
return $"hextoraw('{CommonUtils.BytesSqlRaw(param as byte[])}')";
else if (param is bool || param is bool?)
return (bool)param ? 1 : 0;
else if (param is string || param is char)
else if (param is string)
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
else if (param is char)
return string.Concat("'", param.ToString().Replace("'", "''").Replace('\0', ' '), "'");
else if (param is Enum)
return ((Enum)param).ToInt64();
else if (decimal.TryParse(string.Concat(param), out var trydec))

View File

@ -43,6 +43,7 @@ namespace FreeSql.Odbc.Oracle
{ typeof(byte[]).FullName, CsToDb.New(OdbcType.VarBinary, "blob", "blob NULL", false, null, new byte[0]) },
{ typeof(string).FullName, CsToDb.New(OdbcType.NVarChar, "nvarchar2", "nvarchar2(255) NULL", false, null, "") },
{ typeof(char).FullName, CsToDb.New(OdbcType.Char, "char", "char(1 CHAR) NULL", false, null, '\0') },
{ typeof(Guid).FullName, CsToDb.New(OdbcType.Char, "char", "char(36 CHAR) NOT NULL", false, false, Guid.Empty) },{ typeof(Guid?).FullName, CsToDb.New(OdbcType.Char, "char", "char(36 CHAR) NULL", false, true, null) },
};

View File

@ -42,8 +42,10 @@ namespace FreeSql.Odbc.PostgreSQL
if (param is bool || param is bool?)
return (bool)param ? "'t'" : "'f'";
else if (param is string || param is char)
else if (param is string)
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
else if (param is char)
return string.Concat("'", param.ToString().Replace("'", "''").Replace('\0', ' '), "'");
else if (param is Enum)
return ((Enum)param).ToInt64();
else if (decimal.TryParse(string.Concat(param), out var trydec))

View File

@ -33,6 +33,7 @@ namespace FreeSql.Odbc.PostgreSQL
{ typeof(decimal).FullName, CsToDb.New(OdbcType.Numeric, "numeric", "numeric(10,2) NOT NULL", false, false, 0) },{ typeof(decimal?).FullName, CsToDb.New(OdbcType.Numeric, "numeric", "numeric(10,2)", false, true, null) },
{ typeof(string).FullName, CsToDb.New(OdbcType.VarChar, "varchar", "varchar(255)", false, null, "") },
{ typeof(char).FullName, CsToDb.New(OdbcType.Char, "char", "char(1) NULL", false, null, '\0') },
{ typeof(TimeSpan).FullName, CsToDb.New(OdbcType.Time, "time","time NOT NULL", false, false, 0) },{ typeof(TimeSpan?).FullName, CsToDb.New(OdbcType.Time, "time", "time",false, true, null) },
{ typeof(DateTime).FullName, CsToDb.New(OdbcType.DateTime, "timestamp", "timestamp NOT NULL", false, false, new DateTime(1970,1,1)) },{ typeof(DateTime?).FullName, CsToDb.New(OdbcType.DateTime, "timestamp", "timestamp", false, true, null) },

View File

@ -35,6 +35,7 @@ namespace FreeSql.Odbc.PostgreSQL
{ typeof(ushort).FullName, a => int.Parse(string.Concat(a)) }, { typeof(ushort[]).FullName, a => getParamterArrayValue(typeof(int), a, 0) }, { typeof(ushort?[]).FullName, a => getParamterArrayValue(typeof(int?), a, null) },
{ typeof(byte).FullName, a => short.Parse(string.Concat(a)) }, { typeof(byte[]).FullName, a => getParamterArrayValue(typeof(short), a, 0) }, { typeof(byte?[]).FullName, a => getParamterArrayValue(typeof(short?), a, null) },
{ typeof(sbyte).FullName, a => short.Parse(string.Concat(a)) }, { typeof(sbyte[]).FullName, a => getParamterArrayValue(typeof(short), a, 0) }, { typeof(sbyte?[]).FullName, a => getParamterArrayValue(typeof(short?), a, null) },
{ typeof(char).FullName, a => string.Concat(a).Replace('\0', ' ').ToCharArray().FirstOrDefault() },
};
static object getParamterValue(Type type, object value, int level = 0)
{

View File

@ -50,7 +50,7 @@ namespace FreeSql.Odbc.SqlServer
return string.Concat("N'", param.ToString().Replace("'", "''"), "'");
}
else if (param is char)
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
return string.Concat("'", param.ToString().Replace("'", "''").Replace('\0', ' '), "'");
else if (param is Enum)
return ((Enum)param).ToInt64();
else if (decimal.TryParse(string.Concat(param), out var trydec))

View File

@ -41,6 +41,7 @@ namespace FreeSql.Odbc.SqlServer
{ typeof(byte[]).FullName, CsToDb.New(OdbcType.VarBinary, "varbinary", "varbinary(255)", false, null, new byte[0]) },
{ typeof(string).FullName, CsToDb.New(OdbcType.NVarChar, "nvarchar", "nvarchar(255)", false, null, "") },
{ typeof(char).FullName, CsToDb.New(OdbcType.Char, "char", "char(1) NULL", false, null, '\0') },
{ typeof(Guid).FullName, CsToDb.New(OdbcType.UniqueIdentifier, "uniqueidentifier", "uniqueidentifier NOT NULL", false, false, Guid.Empty) },{ typeof(Guid?).FullName, CsToDb.New(OdbcType.UniqueIdentifier, "uniqueidentifier", "uniqueidentifier", false, true, null) },
};

View File

@ -42,8 +42,10 @@ namespace FreeSql.Oracle
return $"hextoraw('{CommonUtils.BytesSqlRaw(param as byte[])}')";
else if (param is bool || param is bool?)
return (bool)param ? 1 : 0;
else if (param is string || param is char)
else if (param is string)
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
else if (param is char)
return string.Concat("'", param.ToString().Replace("'", "''").Replace('\0', ' '), "'");
else if (param is Enum)
return ((Enum)param).ToInt64();
else if (decimal.TryParse(string.Concat(param), out var trydec))

View File

@ -44,6 +44,7 @@ namespace FreeSql.Oracle
{ typeof(byte[]).FullName, CsToDb.New(OracleDbType.Blob, "blob", "blob NULL", false, null, new byte[0]) },
{ typeof(string).FullName, CsToDb.New(OracleDbType.NVarchar2, "nvarchar2", "nvarchar2(255) NULL", false, null, "") },
{ typeof(char).FullName, CsToDb.New(OracleDbType.Char, "char", "char(1 CHAR) NULL", false, null, '\0') },
{ typeof(Guid).FullName, CsToDb.New(OracleDbType.Char, "char", "char(36 CHAR) NOT NULL", false, false, Guid.Empty) },{ typeof(Guid?).FullName, CsToDb.New(OracleDbType.Char, "char", "char(36 CHAR) NULL", false, true, null) },
};

View File

@ -44,8 +44,10 @@ namespace FreeSql.PostgreSQL
bool isdic;
if (param is bool || param is bool?)
return (bool)param ? "'t'" : "'f'";
else if (param is string || param is char)
else if (param is string)
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
else if (param is char)
return string.Concat("'", param.ToString().Replace("'", "''").Replace('\0', ' '), "'");
else if (param is Enum)
return ((Enum)param).ToInt64();
else if (decimal.TryParse(string.Concat(param), out var trydec))

View File

@ -39,6 +39,7 @@ namespace FreeSql.PostgreSQL
{ typeof(decimal).FullName, CsToDb.New(NpgsqlDbType.Numeric, "numeric", "numeric(10,2) NOT NULL", false, false, 0) },{ typeof(decimal?).FullName, CsToDb.New(NpgsqlDbType.Numeric, "numeric", "numeric(10,2)", false, true, null) },
{ typeof(string).FullName, CsToDb.New(NpgsqlDbType.Varchar, "varchar", "varchar(255)", false, null, "") },
{ typeof(char).FullName, CsToDb.New(NpgsqlDbType.Char, "bpchar", "bpchar(1)", false, null, '\0') },
{ typeof(TimeSpan).FullName, CsToDb.New(NpgsqlDbType.Time, "time","time NOT NULL", false, false, 0) },{ typeof(TimeSpan?).FullName, CsToDb.New(NpgsqlDbType.Time, "time", "time",false, true, null) },
{ typeof(DateTime).FullName, CsToDb.New(NpgsqlDbType.Timestamp, "timestamp", "timestamp NOT NULL", false, false, new DateTime(1970,1,1)) },{ typeof(DateTime?).FullName, CsToDb.New(NpgsqlDbType.Timestamp, "timestamp", "timestamp", false, true, null) },

View File

@ -44,6 +44,7 @@ namespace FreeSql.PostgreSQL
{ typeof(ushort).FullName, a => int.Parse(string.Concat(a)) }, { typeof(ushort[]).FullName, a => getParamterArrayValue(typeof(int), a, 0) }, { typeof(ushort?[]).FullName, a => getParamterArrayValue(typeof(int?), a, null) },
{ typeof(byte).FullName, a => short.Parse(string.Concat(a)) }, { typeof(byte[]).FullName, a => getParamterArrayValue(typeof(short), a, 0) }, { typeof(byte?[]).FullName, a => getParamterArrayValue(typeof(short?), a, null) },
{ typeof(sbyte).FullName, a => short.Parse(string.Concat(a)) }, { typeof(sbyte[]).FullName, a => getParamterArrayValue(typeof(short), a, 0) }, { typeof(sbyte?[]).FullName, a => getParamterArrayValue(typeof(short?), a, null) },
{ typeof(char).FullName, a => string.Concat(a).Replace('\0', ' ').ToCharArray().FirstOrDefault() },
{ typeof(NpgsqlPath).FullName, a => {
var path = (NpgsqlPath)a;
@ -70,6 +71,7 @@ namespace FreeSql.PostgreSQL
static object getParamterValue(Type type, object value, int level = 0)
{
if (type.FullName == "System.Byte[]") return value;
if (type.FullName == "System.Char[]") return value;
if (type.IsArray && level == 0)
{
var elementType = type.GetElementType();

View File

@ -42,8 +42,10 @@ namespace FreeSql.ShenTong
if (param is bool || param is bool?)
return (bool)param ? "'t'" : "'f'";
else if (param is string || param is char)
else if (param is string)
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
else if (param is char)
return string.Concat("'", param.ToString().Replace("'", "''").Replace('\0', ' '), "'");
else if (param is Enum)
return ((Enum)param).ToInt64();
else if (decimal.TryParse(string.Concat(param), out var trydec))

View File

@ -37,6 +37,7 @@ namespace FreeSql.ShenTong
{ typeof(decimal).FullName, CsToDb.New(OscarDbType.Numeric, "numeric", "numeric(10,2) NOT NULL", false, false, 0) },{ typeof(decimal?).FullName, CsToDb.New(OscarDbType.Numeric, "numeric", "numeric(10,2)", false, true, null) },
{ typeof(string).FullName, CsToDb.New(OscarDbType.VarChar, "varchar", "varchar(255)", false, null, "") },
{ typeof(char).FullName, CsToDb.New(OscarDbType.Char, "bpchar", "bpchar(1)", false, null, '\0') },
{ typeof(TimeSpan).FullName, CsToDb.New(OscarDbType.Time, "time","time NOT NULL", false, false, 0) },{ typeof(TimeSpan?).FullName, CsToDb.New(OscarDbType.Time, "time", "time",false, true, null) },
{ typeof(DateTime).FullName, CsToDb.New(OscarDbType.TimeStamp, "timestamp", "timestamp NOT NULL", false, false, new DateTime(1970,1,1)) },{ typeof(DateTime?).FullName, CsToDb.New(OscarDbType.TimeStamp, "timestamp", "timestamp", false, true, null) },
@ -242,7 +243,7 @@ where ns.nspname = {0} and c.relname = {1}", tboldname ?? tbname);
var isCommentChanged = tbstructcol.comment != (tbcol.Comment ?? "");
if (tbcol.Attribute.DbType.StartsWith(tbstructcol.sqlType, StringComparison.CurrentCultureIgnoreCase) == false ||
tbcol.Attribute.DbType.Contains("[]") != (tbstructcol.attndims > 0))
sbalter.Append("ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" ALTER COLUMN ").Append(_commonUtils.QuoteSqlName(tbstructcol.column)).Append(" TYPE ").Append(tbcol.Attribute.DbType.Split(' ').First()).Append(";\r\n");
sbalter.Append("ALTER TABLE ").Append(_commonUtils.QuoteSqlName($"{tbname[0]}.{tbname[1]}")).Append(" ALTER TYPE ").Append(_commonUtils.QuoteSqlName(tbstructcol.column)).Append(" ").Append(tbcol.Attribute.DbType.Split(' ').First()).Append(";\r\n");
if (tbcol.Attribute.IsNullable != tbstructcol.is_nullable)
{
if (tbcol.Attribute.IsNullable != true || tbcol.Attribute.IsNullable == true && tbcol.Attribute.IsPrimary == false)

View File

@ -38,6 +38,7 @@ namespace FreeSql.ShenTong
{ typeof(ushort).FullName, a => int.Parse(string.Concat(a)) }, { typeof(ushort[]).FullName, a => getParamterArrayValue(typeof(int), a, 0) }, { typeof(ushort?[]).FullName, a => getParamterArrayValue(typeof(int?), a, null) },
{ typeof(byte).FullName, a => short.Parse(string.Concat(a)) }, { typeof(byte[]).FullName, a => getParamterArrayValue(typeof(short), a, 0) }, { typeof(byte?[]).FullName, a => getParamterArrayValue(typeof(short?), a, null) },
{ typeof(sbyte).FullName, a => short.Parse(string.Concat(a)) }, { typeof(sbyte[]).FullName, a => getParamterArrayValue(typeof(short), a, 0) }, { typeof(sbyte?[]).FullName, a => getParamterArrayValue(typeof(short?), a, null) },
{ typeof(char).FullName, a => string.Concat(a).Replace('\0', ' ').ToCharArray().FirstOrDefault() },
};
static object getParamterValue(Type type, object value, int level = 0)
{

View File

@ -51,7 +51,7 @@ namespace FreeSql.SqlServer
return string.Concat("N'", param.ToString().Replace("'", "''"), "'");
}
else if (param is char)
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
return string.Concat("'", param.ToString().Replace("'", "''").Replace('\0', ' '), "'");
else if (param is Enum)
return ((Enum)param).ToInt64();
else if (decimal.TryParse(string.Concat(param), out var trydec))

View File

@ -40,6 +40,7 @@ namespace FreeSql.SqlServer
{ typeof(byte[]).FullName, CsToDb.New(SqlDbType.VarBinary, "varbinary", "varbinary(255)", false, null, new byte[0]) },
{ typeof(string).FullName, CsToDb.New(SqlDbType.NVarChar, "nvarchar", "nvarchar(255)", false, null, "") },
{ typeof(char).FullName, CsToDb.New(SqlDbType.Char, "char", "char(1)", false, null, '\0') },
{ typeof(Guid).FullName, CsToDb.New(SqlDbType.UniqueIdentifier, "uniqueidentifier", "uniqueidentifier NOT NULL", false, false, Guid.Empty) },{ typeof(Guid?).FullName, CsToDb.New(SqlDbType.UniqueIdentifier, "uniqueidentifier", "uniqueidentifier", false, true, null) },
};

View File

@ -43,8 +43,10 @@ namespace FreeSql.Sqlite
if (param is bool || param is bool?)
return (bool)param ? 1 : 0;
else if (param is string || param is char)
else if (param is string)
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
else if (param is char)
return string.Concat("'", param.ToString().Replace("'", "''").Replace('\0', ' '), "'");
else if (param is Enum)
return ((Enum)param).ToInt64();
else if (decimal.TryParse(string.Concat(param), out var trydec))

View File

@ -38,6 +38,7 @@ namespace FreeSql.Sqlite
{ typeof(byte[]).FullName, CsToDb.New(DbType.Binary, "blob", "blob", false, null, new byte[0]) },
{ typeof(string).FullName, CsToDb.New(DbType.String, "nvarchar", "nvarchar(255)", false, null, "") },
{ typeof(char).FullName, CsToDb.New(DbType.AnsiString, "char", "char(1)", false, null, '\0') },
{ typeof(Guid).FullName, CsToDb.New(DbType.Guid, "character", "character(36) NOT NULL", false, false, Guid.Empty) },{ typeof(Guid?).FullName, CsToDb.New(DbType.Guid, "character", "character(36)", false, true, null) },
};