Join between in memory collection and EntityFramework

前端 未结 4 1335
闹比i
闹比i 2020-12-30 04:11

Is there any mechanism for doing a JOIN between an in-memory collection and entity framework while preserving the order.

What I am trying is

var ite         


        
4条回答
  •  长发绾君心
    2020-12-30 04:25

    No you cannot join in-memory collection with database result set without loading whole result set to the memory and performing the join with linq-to-objects. Try using contains instead of join:

    var myNumbers = myInMemoryList.Select(i => i.RECORD_NUMBER);
    var itemsToAdd = efRepo.Where(e => myNumbers.Contains(e.RECORD_NUMBER));
    

    This will generate query with IN operator

提交回复
热议问题