How to avoid Query Plan re-compilation when using IEnumerable.Contains in Entity Framework LINQ queries?

前端 未结 3 1358
谎友^
谎友^ 2020-12-23 09:51

I have the following LINQ query executed using Entity Framework (v6.1.1):

private IList GetFullCustomers(IEnumerable customersIds)         


        
3条回答
  •  甜味超标
    2020-12-23 10:29

    This is really a huge problem, and there's no one-size-fits-all answer. However, when most lists are relatively small, diverga's "Second Workaround" works well. I've built a library distributed as a NuGet package to perform this transformation with as little modification to the query as possible:

    https://github.com/bchurchill/EFCacheContains

    It's been tested out in one project, but feedback and user experiences would be appreciated! If any issues come up please report on github so that I can follow-up.

提交回复
热议问题