-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用Z.EntityFramework.Plus报错 #179
Comments
@Hexiang1128 批处理三方的查看文档里面的批处理兼容,因为三方批处理不属于efcore api但是shardingcore做了兼容直接看文档就知道了 |
@Hexiang1128 不好意思我一开始以为是批处理的增删改查,原来是将多个查询聚合成一批然后查询这个功能目前不支持不好意思,后续可以考虑支持 因为是三方的api所以我自己了解的不多抱歉啊需要后续做支持 |
@xuejmnet 谢谢,希望能够尽快支持 |
同问: 在批量删除时错误,不用批量删除会全部查出来一个一个删除,非常慢 Unable to cast object of type 'ShardingCore.EFCores.ShardingQueryCompiler' to type 'Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler'.
System.InvalidCastException: Unable to cast object of type 'ShardingCore.EFCores.ShardingQueryCompiler' to type 'Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler'.
at .[](IQueryable`1 )
at Z.EntityFramework.Extensions.BatchDelete.Execute[T](IQueryable`1 query) |
@zh3305 不需要查询出来上面已经给解决方案了批量处理兼容任何三方框架 |
@xuejmnet 我用的 就是 Z.EntityFramework.Plus 插件的 Repository.GetAll() .DeleteAsync(); 功能. |
@zh3305 这个不是zzz的bug是因为shardingcore替换了IQuerycompiler导致的不过我已经写了兼容的代码可以查看文档,刚刚我又把demo写了一下你可以看看 |
@xuejmnet 感谢大佬 搞定了 public static async Task<int> ShardingBulkDeleteAsync<T>(this MonitorDbContext shardingDbContext, Expression<Func<T, bool>> where,
CancellationToken cancellationToken = default(CancellationToken)) where T : class
{
var dbContexts = shardingDbContext.BulkShardingTableExpression(where);
var effectRows = 0;
foreach (var dbContext in dbContexts)
{
effectRows += await dbContext.Set<T>().Where(where)
.DeleteAsync( cancellationToken: cancellationToken);
}
return effectRows;
}
|
@zh3305 嗯好的 :) |
@zh3305 后续我尝试把ShardingCore的ShardingQueryComplier通过继承QueryComplier来实现分片目前是直接继承的接口,如果通过继承父类起码未分片的表不会报错,只有分片表会报错报找不到表这样或许好一点 |
…这样可以保证未分片的表使用zzz不需要处理修改还是支持的,仅分片表处理需要特殊考虑
@zh3305 @Hexiang1128 最新版本6.8.0.7和7.0.0.2已经修复了针对普通对象的操作,仅分片对象需要特殊处理:) |
报错提示:Unable to cast object of type 'ShardingCore.EFCores.ShardingQueryCompiler' to type 'Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler'.
使用的是Z.EntityFramework.Plus查询未来的功能所产生的报错:source.DeferredCount().FutureValue();
请问这个如何解决?
The text was updated successfully, but these errors were encountered: