- FreeSql.Generator 类型映射容错判断;

This commit is contained in:
28810 2019-12-22 01:15:38 +08:00
parent a17917e172
commit 35829f9010
3 changed files with 38 additions and 12 deletions

View File

@ -66,6 +66,8 @@ public class RazorModel {
if (GetCsName(col.Name) != col.Name)
sb.Add("Name = \"" + col.Name + "\"");
if (col.CsType != null)
{
var dbinfo = fsql.CodeFirst.GetDbInfo(col.CsType);
if (dbinfo != null && dbinfo.Value.dbtypeFull.Replace("NOT NULL", "").Trim() != col.DbTypeTextFull)
sb.Add("DbType = \"" + col.DbTypeTextFull + "\"");
@ -74,12 +76,14 @@ public class RazorModel {
if (col.IsIdentity)
sb.Add("IsIdentity = true");
if (dbinfo != null && dbinfo.Value.isnullable != col.IsNullable) {
if (dbinfo != null && dbinfo.Value.isnullable != col.IsNullable)
{
if (col.IsNullable && fsql.DbFirst.GetCsType(col).Contains("?") == false && col.CsType.IsValueType)
sb.Add("IsNullable = true");
if (col.IsNullable == false && fsql.DbFirst.GetCsType(col).Contains("?") == true)
sb.Add("IsNullable = false");
}
}
if (sb.Any() == false) return null;
return "[Column(" + string.Join(", ", sb) + ")]";
}

View File

@ -110,6 +110,13 @@
清空状态数据
</summary>
</member>
<member name="M:FreeSql.DbSet`1.RemoveAsync(System.Linq.Expressions.Expression{System.Func{`0,System.Boolean}})">
<summary>
根据 lambda 条件删除数据
</summary>
<param name="predicate"></param>
<returns></returns>
</member>
<member name="M:FreeSql.DbSet`1.Add(`0)">
<summary>
添加

View File

@ -83,6 +83,21 @@ public class g
.Build());
public static IFreeSql dameng => damemgLazy.Value;
static Lazy<IFreeSql> gbaseLazy = new Lazy<IFreeSql>(() => new FreeSql.FreeSqlBuilder()
.UseConnectionString(FreeSql.DataType.OdbcDameng, "Driver={DM8 ODBC DRIVER};Server=127.0.0.1:5236;Persist Security Info=False;Trusted_Connection=Yes;UID=USER1;PWD=123456789")
//.UseConnectionFactory(FreeSql.DataType.OdbcDameng, () => new System.Data.Odbc.OdbcConnection("Driver={DM8 ODBC DRIVER};Server=127.0.0.1:5236;Persist Security Info=False;Trusted_Connection=Yes;UID=USER1;PWD=123456789"))
.UseAutoSyncStructure(true)
.UseLazyLoading(true)
.UseSyncStructureToUpper(true)
//.UseNoneCommandParameter(true)
.UseMonitorCommand(
cmd => Trace.WriteLine(cmd.CommandText), //监听SQL命令对象在执行前
(cmd, traceLog) => Console.WriteLine(traceLog))
.Build());
public static IFreeSql gbase => gbaseLazy.Value;
//启动神州通用数据库 /etc/init.d/oscardb_OSRDBd start
//SYSDBA 密码 szoscar55