Browse Source

Update Oracle delete list

pull/11/head
sunkaixuna 3 years ago
parent
commit
0f40c4f63b
  1. 1
      Src/Asp.Net/OracleTest/UnitTest/Main.cs
  2. 46
      Src/Asp.Net/OracleTest/UnitTest/UDelete.cs
  3. 11
      Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs

1
Src/Asp.Net/OracleTest/UnitTest/Main.cs

@ -34,6 +34,7 @@ namespace OrmTest
}
public static void Init()
{
DeleteTest();
CodeFirst();
Updateable();
Json();

46
Src/Asp.Net/OracleTest/UnitTest/UDelete.cs

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest
{
public partial class NewUnitTest
{
public static void DeleteTest()
{
Db.CodeFirst.InitTables<UnitDel12311>();
var list = new List<UnitDel12311>() {
new UnitDel12311(){
Date1=DateTime.Now,
ID=Guid.NewGuid(),Name="a"
},
new UnitDel12311(){
Date1=DateTime.Now,
ID=Guid.NewGuid(),Name="a"
}
};
var db = Db;
db.CurrentConnectionConfig.MoreSettings = new SqlSugar.ConnMoreSettings()
{
DisableNvarchar=true
};
db.Insertable(list).ExecuteCommand();
var r= db.Deleteable(list).ExecuteCommand();
if (r == 0)
{
throw new Exception("unit test delete");
}
}
public class UnitDel12311
{
[SqlSugar.SugarColumn(IsPrimaryKey =true)]
public Guid ID { get; set; }
[SqlSugar.SugarColumn(IsPrimaryKey = true)]
public DateTime Date1 { get; set; }
public string Name { get; set; }
}
}
}

11
Src/Asp.Net/SqlSugar/Abstract/DeleteProvider/DeleteableProvider.cs

@ -143,11 +143,18 @@ namespace SqlSugar
var tempequals = DeleteBuilder.WhereInEqualTemplate;
if (this.Context.CurrentConnectionConfig.MoreSettings != null && this.Context.CurrentConnectionConfig.MoreSettings.DisableNvarchar == true)
{
tempequals = "\"{0}\"={1} ";
tempequals = "\"{0}\"='{1}' ";
}
if (this.Context.CurrentConnectionConfig.DbType == DbType.Oracle)
{
andString.AppendFormat(tempequals, primaryField.ToUpper(), entityValue);
if (entityValue != null && UtilMethods.GetUnderType(entityValue.GetType()) == UtilConstants.DateType)
{
andString.AppendFormat("\"{0}\"={1} ", primaryField.ToUpper(), "to_date('" + entityValue.ObjToDate().ToString("yyyy-MM-dd HH:mm:ss") + "', 'YYYY-MM-DD HH24:MI:SS') ");
}
else
{
andString.AppendFormat(tempequals, primaryField.ToUpper(), entityValue);
}
}
else if (this.Context.CurrentConnectionConfig.DbType == DbType.PostgreSQL&& (this.Context.CurrentConnectionConfig.MoreSettings==null||this.Context.CurrentConnectionConfig.MoreSettings?.PgSqlIsAutoToLower==true))
{

Loading…
Cancel
Save