diff --git a/Src/Asp.Net/MySqlTest/UnitTest/UInsert.cs b/Src/Asp.Net/MySqlTest/UnitTest/UInsert.cs index 53cb2d67e..14f81ef67 100644 --- a/Src/Asp.Net/MySqlTest/UnitTest/UInsert.cs +++ b/Src/Asp.Net/MySqlTest/UnitTest/UInsert.cs @@ -11,9 +11,9 @@ namespace OrmTest { public class Unit4ASDF { - [SqlSugar.SugarColumn(ColumnDataType = " bigint(20)",IsNullable =true)] + [SqlSugar.SugarColumn(ColumnDataType = " bigint(20)", IsNullable = true)] public long? Id { get; set; } - [SqlSugar.SugarColumn(ColumnDataType = " bigint(20)" )] + [SqlSugar.SugarColumn(ColumnDataType = " bigint(20)")] public long Id2 { get; set; } } public static void Insert() @@ -72,6 +72,12 @@ namespace OrmTest } } + + Db.CodeFirst.InitTables(); + Db.DbMaintenance.TruncateTable("Testdbbool"); + Db.Insertable(new Testdbbool() { isok=true }).UseMySql().ExecuteBlueCopy(); + Db.Insertable(new Testdbbool() { isok = false }).UseMySql().ExecuteBlueCopy(); + var x=Db.Queryable().ToList(); } public class testdb @@ -81,5 +87,12 @@ namespace OrmTest public string id { get; set; } } + + public class Testdbbool + { + [SqlSugar.SugarColumn(IsPrimaryKey = true,IsIdentity =true)] + public int id { get; set; } + public bool isok { get; set; } + } } } diff --git a/Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlBlueCopy.cs b/Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlBlueCopy.cs index ed877b775..3c9dfc489 100644 --- a/Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlBlueCopy.cs +++ b/Src/Asp.Net/SqlSugar/Realization/MySql/SqlBuilder/MySqlBlueCopy.cs @@ -60,9 +60,9 @@ namespace SqlSugar var name = p.Name; if (entity.Columns.Any(it => it.PropertyName == name)) { - name=entity.Columns.First(it => it.PropertyName == name).DbColumnName; + name = entity.Columns.First(it => it.PropertyName == name).DbColumnName; } - row[name] = p.GetValue(item, null); + row[name] = GetValue(p, item); }); dt.Rows.Add(row); } @@ -169,7 +169,22 @@ namespace SqlSugar sb.AppendLine(); } return sb.ToString(); - } + } + + + private static object GetValue(PropertyInfo p, T item) + { + var result= p.GetValue(item, null); + if (result != null && UtilMethods.GetUnderType(p.PropertyType) == UtilConstants.BoolType) + { + if (result.ObjToBool() == false) + { + result = null; + } + } + return result; + } + #endregion } } \ No newline at end of file