临时修改
parent
dfeab8793f
commit
4a2fd0166e
|
@ -5,7 +5,6 @@ using IRaCIS.Core.Application.Helper;
|
|||
using IRaCIS.Core.Application.Service;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.SqlServer.Query.Internal;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
|
|
|
@ -571,6 +571,8 @@ namespace IRaCIS.Core.Application.Service
|
|||
SqlParameter[] paravalue = new SqlParameter[] {
|
||||
new SqlParameter("@para",para)
|
||||
};
|
||||
|
||||
//https://learn.microsoft.com/zh-tw/ef/core/querying/sql-queries
|
||||
jsonDataValueDic[item.Key] = string.Join(",", _frontAuditConfigRepository._dbContext.Database.SqlQuery<ForeignKey>(sql, paravalue).Select(x => x.Text).ToList());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
using System;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Collections.Generic;
|
||||
using EntityFrameworkCore.Projectables;
|
||||
using System.Linq;
|
||||
|
||||
namespace IRaCIS.Core.Domain.Models
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
dbConn = conn;
|
||||
conn.Open();
|
||||
DbCommand cmd = conn.CreateCommand();
|
||||
if (facade.IsSqlServer())
|
||||
if (facade.IsRelational())
|
||||
{
|
||||
cmd.CommandText = sql;
|
||||
CombineParams(ref cmd, parameters);
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
using EFCore.BulkExtensions;
|
||||
using AutoMapper.Internal;
|
||||
using EFCore.BulkExtensions;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Query;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
|
@ -166,6 +169,9 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
{
|
||||
if (where == null) throw new ArgumentNullException(nameof(where));
|
||||
|
||||
|
||||
#region batch delete bug
|
||||
|
||||
var bindings = ((MemberInitExpression)updateFactory.Body).Bindings.ToList();
|
||||
|
||||
var hasPropNameList = bindings.Select(t => t.Member.Name).ToList();
|
||||
|
@ -193,12 +199,74 @@ namespace IRaCIS.Core.Infra.EFCore
|
|||
var factory = Expression.Lambda<Func<T, T>>(member, Expression.Parameter(typeof(T), "x"));
|
||||
|
||||
|
||||
|
||||
return await _dbContext.Set<T>().IgnoreQueryFilters().Where(where).BatchUpdateAsync(factory).ConfigureAwait(false) > 0;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region efcore 7
|
||||
|
||||
//Dictionary<string, object> propValues = new Dictionary<string, object>();
|
||||
|
||||
//// 获取表达式体的 MemberInitExpression
|
||||
//var memberInitExpr = (MemberInitExpression)updateFactory.Body;
|
||||
|
||||
|
||||
|
||||
//// 获取初始化的绑定信息
|
||||
//var bindings = memberInitExpr.Bindings.ToList();
|
||||
|
||||
//var hasPropNameList = bindings.Select(t => t.Member.Name).ToList();
|
||||
|
||||
|
||||
//// 遍历绑定信息
|
||||
//foreach (MemberAssignment binding in bindings)
|
||||
//{
|
||||
// // 获取属性名
|
||||
// string propName = binding.Member.Name;
|
||||
|
||||
// // 获取属性值,需要对表达式进行编译和调用
|
||||
// var propValue = Expression.Lambda(binding.Expression).Compile().DynamicInvoke();
|
||||
|
||||
// // 现在,你可以访问属性名和属性值
|
||||
// propValues.Add(propName, propValue);
|
||||
//}
|
||||
|
||||
//if (typeof(IAuditUpdate).IsAssignableFrom(typeof(T)))
|
||||
//{
|
||||
|
||||
// if (!hasPropNameList.Contains(nameof(IAuditUpdate.UpdateTime)))
|
||||
// {
|
||||
// propValues.Add(nameof(IAuditUpdate.UpdateTime), DateTime.Now);
|
||||
|
||||
|
||||
// }
|
||||
|
||||
// if (!hasPropNameList.Contains(nameof(IAuditUpdate.UpdateUserId)))
|
||||
// {
|
||||
// propValues.Add(nameof(IAuditUpdate.UpdateUserId), updateUserId);
|
||||
|
||||
// }
|
||||
|
||||
//}
|
||||
|
||||
//return await _dbContext.Set<T>().IgnoreQueryFilters().Where(where).ExecuteUpdateAsync(s => s.SetProperty(t => "UpdateTime", u => "").se).ConfigureAwait(false) > 0;
|
||||
|
||||
////return await _dbContext.Set<T>().IgnoreQueryFilters().Where(where).ExecuteUpdateAsync(propValues.SetProperties<T>()).ConfigureAwait(false) > 0;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ using System.Linq;
|
|||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using EFCore.BulkExtensions;
|
||||
using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace IRaCIS.Core.Infra.EFCore
|
||||
|
|
|
@ -10,7 +10,6 @@ using IRaCIS.Core.Domain.Models;
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using AutoMapper.QueryableExtensions;
|
||||
using EFCore.BulkExtensions;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infrastructure;
|
||||
using IRaCIS.Core.Infrastructure.Extention;
|
||||
|
|
|
@ -11,9 +11,11 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="12.0.1" />
|
||||
<PackageReference Include="CSRedisCore" Version="3.8.671" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.12" />
|
||||
<PackageReference Include="EFCore.BulkExtensions" Version="7.1.6" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.10" />
|
||||
<PackageReference Include="EntityFrameworkCore.Exceptions.SqlServer" Version="6.0.3.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.10" />
|
||||
<PackageReference Include="SharpCompress" Version="0.34.1" />
|
||||
<PackageReference Include="SharpZipLib" Version="1.4.2" />
|
||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.5" />
|
||||
|
|
Loading…
Reference in New Issue