diff --git a/Src/Asp.Net/PgSqlTest/UnitTest/Updateable.cs b/Src/Asp.Net/PgSqlTest/UnitTest/Updateable.cs index 444b8e0e3..8ec8cc2a1 100644 --- a/Src/Asp.Net/PgSqlTest/UnitTest/Updateable.cs +++ b/Src/Asp.Net/PgSqlTest/UnitTest/Updateable.cs @@ -70,9 +70,28 @@ namespace OrmTest .Where(it => it.a) .ExecuteCommand(); + // Db.CodeFirst.InitTables(); + //Db.CodeFirst.InitTables(); + //Db.Deleteable().Where(new UnitPk00121() { Id=1, CreateTime=DateTime.Now, Name="a" }).ExecuteCommand(); + //Db.Deleteable().Where(new List { new UnitPk001212() { Id = 1, CreateTime = DateTime.Now, Name = "a" } , new UnitPk001212() { Id = 2, CreateTime = DateTime.Now, Name = "11a" } }).ExecuteCommand(); } } - + public class UnitPk00121 + { + [SugarColumn(IsPrimaryKey = true)] + public int Id { get; set; } + [SugarColumn(IsPrimaryKey = true)] + public DateTime? CreateTime { get; set; } + public string Name { get; set; } + } + public class UnitPk001212 + { + [SugarColumn(IsPrimaryKey = true)] + public int Id { get; set; } + public DateTime? CreateTime { get; set; } + [SugarColumn(IsPrimaryKey = true)] + public string Name { get; set; } + } public class BoolTest1 { public bool a { get; set; } diff --git a/Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs index 311aac329..766d2cb9e 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs @@ -144,6 +144,10 @@ namespace SqlSugar { andString.AppendFormat(DeleteBuilder.WhereInEqualTemplate, primaryField.ToUpper(), entityValue); } + else if (this.Context.CurrentConnectionConfig.DbType == DbType.PostgreSQL&& (this.Context.CurrentConnectionConfig.MoreSettings==null||this.Context.CurrentConnectionConfig.MoreSettings?.PgSqlIsAutoToLower==true)) + { + andString.AppendFormat("\"{0}\"={1} ", primaryField.ToLower(), new PostgreSQLExpressionContext().GetValue(entityValue)); + } else { andString.AppendFormat(DeleteBuilder.WhereInEqualTemplate, primaryField, entityValue); diff --git a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLExpressionContext.cs b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLExpressionContext.cs index 1a31dd6f5..97bd3f200 100644 --- a/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLExpressionContext.cs +++ b/Src/Asp.Net/SqlSugar/Realization/PostgreSQL/SqlBuilder/PostgreSQLExpressionContext.cs @@ -101,6 +101,35 @@ namespace SqlSugar return propertyName.ToLower(isAutoToLower); } } + + public string GetValue(object entityValue) + { + if (entityValue == null) + return null; + var type = UtilMethods.GetUnderType(entityValue.GetType()); + if (UtilConstants.NumericalTypes.Contains(type)) + { + return entityValue.ToString(); + } + else if (type == UtilConstants.DateType) + { + return this.DbMehtods.ToDate(new MethodCallExpressionModel() + { + Args = new System.Collections.Generic.List() { + new MethodCallExpressionArgs(){ MemberName=$"'{entityValue}'" } + } + }); + } + else + { + return this.DbMehtods.ToString(new MethodCallExpressionModel() + { + Args = new System.Collections.Generic.List() { + new MethodCallExpressionArgs(){ MemberName=$"'{entityValue}'" } + } + }); + } + } } public class PostgreSQLMethod : DefaultDbMethod, IDbMethods {