- 修复 FreeSql.Generator 默认值 NULL 处理问题;#645

This commit is contained in:
2881099 2021-01-14 17:54:56 +08:00
parent 02785f4b8a
commit 013eec2264

View File

@ -220,6 +220,7 @@ public class RazorModel {
if (defval.StartsWith("N'") && defval.EndsWith("'")) defval = defval.Substring(1); if (defval.StartsWith("N'") && defval.EndsWith("'")) defval = defval.Substring(1);
if (cstype == typeof(Guid) && string.Compare(defval, "newid()", true) == 0) return $"Guid.NewGuid()"; if (cstype == typeof(Guid) && string.Compare(defval, "newid()", true) == 0) return $"Guid.NewGuid()";
if (cstype == typeof(string) && string.Compare(defval, "newid()", true) == 0) return $"Guid.NewGuid().ToString().ToUpper()"; if (cstype == typeof(string) && string.Compare(defval, "newid()", true) == 0) return $"Guid.NewGuid().ToString().ToUpper()";
if (defval == "NULL") return null;
} }
if ((cstype == typeof(string) && defval.StartsWith("'") && defval.EndsWith("'::character varying") || if ((cstype == typeof(string) && defval.StartsWith("'") && defval.EndsWith("'::character varying") ||
cstype == typeof(Guid) && defval.StartsWith("'") && defval.EndsWith("'::uuid") cstype == typeof(Guid) && defval.StartsWith("'") && defval.EndsWith("'::uuid")