From 35829f9010be761067f339e358dc6e954837f8a6 Mon Sep 17 00:00:00 2001 From: 28810 <28810@YEXIANGQIN> Date: Sun, 22 Dec 2019 01:15:38 +0800 Subject: [PATCH] =?UTF-8?q?-=20FreeSql.Generator=20=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E6=98=A0=E5=B0=84=E5=AE=B9=E9=94=99=E5=88=A4=E6=96=AD=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Extensions/FreeSql.Generator/RazorModel.cs | 28 +++++++++++-------- FreeSql.DbContext/FreeSql.DbContext.xml | 7 +++++ .../FreeSql.Tests.Provider.Odbc/g.cs | 15 ++++++++++ 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/Extensions/FreeSql.Generator/RazorModel.cs b/Extensions/FreeSql.Generator/RazorModel.cs index 80f7a855..d754ee2f 100644 --- a/Extensions/FreeSql.Generator/RazorModel.cs +++ b/Extensions/FreeSql.Generator/RazorModel.cs @@ -66,19 +66,23 @@ public class RazorModel { if (GetCsName(col.Name) != col.Name) sb.Add("Name = \"" + col.Name + "\""); - var dbinfo = fsql.CodeFirst.GetDbInfo(col.CsType); - if (dbinfo != null && dbinfo.Value.dbtypeFull.Replace("NOT NULL", "").Trim() != col.DbTypeTextFull) - sb.Add("DbType = \"" + col.DbTypeTextFull + "\""); - if (col.IsPrimary) - sb.Add("IsPrimary = true"); - if (col.IsIdentity) - sb.Add("IsIdentity = true"); + 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 + "\""); + if (col.IsPrimary) + sb.Add("IsPrimary = true"); + if (col.IsIdentity) + sb.Add("IsIdentity = true"); - 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 (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) + ")]"; diff --git a/FreeSql.DbContext/FreeSql.DbContext.xml b/FreeSql.DbContext/FreeSql.DbContext.xml index dc0203b8..d9f91124 100644 --- a/FreeSql.DbContext/FreeSql.DbContext.xml +++ b/FreeSql.DbContext/FreeSql.DbContext.xml @@ -110,6 +110,13 @@ 清空状态数据 + + + 根据 lambda 条件删除数据 + + + + 添加 diff --git a/FreeSql.Tests/FreeSql.Tests.Provider.Odbc/g.cs b/FreeSql.Tests/FreeSql.Tests.Provider.Odbc/g.cs index bd719336..7ae66c0d 100644 --- a/FreeSql.Tests/FreeSql.Tests.Provider.Odbc/g.cs +++ b/FreeSql.Tests/FreeSql.Tests.Provider.Odbc/g.cs @@ -83,6 +83,21 @@ public class g .Build()); public static IFreeSql dameng => damemgLazy.Value; + + static Lazy gbaseLazy = new Lazy(() => 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