yangzhongke / Zack.EFCore.Batch

Deleting or Updating multiple records from a LINQ Query in a SQL statement without loading entities
GNU General Public License v3.0
590 stars 85 forks source link

BatchUpdate传递实体中使用枚举类型会被替换 #125

Closed hhweijun closed 9 months ago

hhweijun commented 10 months ago

在Zack.EFCore.Batch_NET6中,批量更新传的枚举类型选择默认接受为首个传递值,可以调整嘛

hhweijun commented 10 months ago

大佬,在翻阅过往的更改记录中看到了 这是个不能修复的问题

hhweijun commented 10 months ago

///

/// Set(c=>c.Name,"hello") /// /// /// /// /// public BatchUpdateBuilder Set(Expression<Func<TEntity, TP>> nameExpr, TP value) { var propertyType = typeof(TP); //fix https://github.com/yangzhongke/Zack.EFCore.Batch/issues/47 Expression valueExpr = Expression.Constant(value, propertyType); //var pExpr = Expression.Parameter(typeof(TEntity)); var pExpr = Expression.Parameter(typeof(TEntity), value.GetType().ToString()); var valueLambdaExpr = Expression.Lambda<Func<TEntity,TP>>(valueExpr, pExpr); return Set(nameExpr, valueLambdaExpr, propertyType); } set 时 转换的值的参数值获取一下类型可以让枚举的值不被替换

yangzhongke commented 9 months ago

抱歉,没有听明白你说的“选择默认接受为首个传递值”是什么意思,value就是一个值呀,你传什么值他就是什么值呀? 能提供一下复现的方式吗?代码是什么样的,期望是什么,实际是什么。

hhweijun commented 9 months ago

抱歉,没说清楚,是传入多个枚举类型。

hhweijun commented 9 months ago

https://github.com/yangzhongke/Zack.EFCore.Batch/issues/69 跟这个一样

yangzhongke commented 9 months ago

谢谢,已经修改并发布,大约15分钟后升级到最新版Nuget即可。