diff --git a/Src/Asp.Net/SqlServerTest/Program.cs b/Src/Asp.Net/SqlServerTest/Program.cs index f600785c3..6d46a63bf 100644 --- a/Src/Asp.Net/SqlServerTest/Program.cs +++ b/Src/Asp.Net/SqlServerTest/Program.cs @@ -27,7 +27,7 @@ namespace OrmTest DemoA_DbMain.Init(); DemoB_Aop.Init(); DemoC_GobalFilter.Init(); - DemoD_DbFirst.Init();; + //DemoD_DbFirst.Init();; DemoE_CodeFirst.Init(); DemoF_Utilities.Init(); DemoG_SimpleClient.Init(); @@ -36,7 +36,7 @@ namespace OrmTest DemoL_Snowflake.Init(); DemoM_UnitOfWork.Init(); //Unit test - NewUnitTest.Init(); + //NewUnitTest.Init(); //Rest Data NewUnitTest.RestData(); diff --git a/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj b/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj index 50bc783e7..1140804a6 100644 --- a/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj +++ b/Src/Asp.Net/SqlServerTest/SqlServerTest.csproj @@ -99,6 +99,7 @@ + diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/Main.cs b/Src/Asp.Net/SqlServerTest/UnitTest/Main.cs index 5cf97a64a..9cb5f183e 100644 --- a/Src/Asp.Net/SqlServerTest/UnitTest/Main.cs +++ b/Src/Asp.Net/SqlServerTest/UnitTest/Main.cs @@ -31,6 +31,7 @@ namespace OrmTest } public static void Init() { + UCustom016.Init(); UCustom015.Init(); UCustom014.Init(); UCustom013.Init(); diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/UCustom016.cs b/Src/Asp.Net/SqlServerTest/UnitTest/UCustom016.cs new file mode 100644 index 000000000..1d594e7cc --- /dev/null +++ b/Src/Asp.Net/SqlServerTest/UnitTest/UCustom016.cs @@ -0,0 +1,60 @@ +using OrmTest.UnitTest.Models; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OrmTest +{ + public class UCustom016 + { + + public static void Init() + { + var db = NewUnitTest.Db; + + + + db.CodeFirst.InitTables(); + db.DbMaintenance.TruncateTable(); + db.DbMaintenance.TruncateTable(); + db.DbMaintenance.TruncateTable(); + db.Insertable(new A1() { Id = Guid.NewGuid(), Name = "a1" }).ExecuteCommand(); + + db.Insertable(new B1() { Id = Guid.NewGuid(), Name = "b1" }).ExecuteCommand(); + db.Insertable(new B1() { Id = Guid.NewGuid(), Name = "b2" }).ExecuteCommand(); + db.Insertable(new ABMapping1() { AId = Guid.NewGuid(), BId = Guid.NewGuid() }).ExecuteCommand(); + db.Queryable().Includes(X => X.BList).ToList(); + } + [SugarTable("ABMapping1Guid")] + public class ABMapping1 + { + [SugarColumn(IsPrimaryKey = true )] + public Guid AId { get; set; } + [SugarColumn(IsPrimaryKey = true)] + public Guid BId { get; set; } + } + [SugarTable("A1Guid")] + public class A1 + { + [SugarColumn(IsPrimaryKey = true )] + public Guid Id { get; set; } + public string Name { get; set; } + [Navigate(typeof(ABMapping1),nameof(ABMapping1.AId),nameof(ABMapping1.BId))] + public List BList { get; set; } + } + [SugarTable("B1Guid")] + public class B1 + { + [SugarColumn(IsPrimaryKey = true )] + public Guid Id { get; set; } + public string Name { get; set; } + [Navigate(typeof(ABMapping1), nameof(ABMapping1.BId), nameof(ABMapping1.AId))] + public List AList { get; set; } + } + + + } +} diff --git a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider.cs index 0f22a2399..9a4480915 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/SqlBuilderProvider/SqlBuilderProvider.cs @@ -201,6 +201,10 @@ namespace SqlSugar { inValue1 = inValue1.Replace("[null]", "null"); } + if (item.CSharpTypeName.EqualCase("guid")&& inValue1=="('')") + { + inValue1 = $"('{Guid.Empty.ToString()}')"; + } builder.AppendFormat(temp, type, item.FieldName.ToSqlFilter(), "IN", inValue1); parameters.Add(new SugarParameter(parameterName, item.FieldValue)); break;