简体   繁体   中英

Using DbQuery in linq join -> Entity Framework Core

I have a query ( DeliveryDates ) and a dbset ( Products ) in EF Core and I want to join them in linq.

I tried this:

var list = await (from d in _financeContext.DeliveryDates
                  join p in _financeContext.Products on d.ProductId equals p.ProductId
                  select new
                          {
                          }).ToListAsync();

But I get this error:

Could not find an implementation of the query pattern for source type 'DbQuery'. 'Join' not found. (CS1936)

Is there anyway to join a dbquery and a dbset in linq ?

join is a Linq function. It looks like you don't add a using to System.Linq;

using System.Linq;

var list = await (from d in _financeContext.DeliveryDates
              join p in _financeContext.Products on d.ProductId equals p.ProductId
              select new
                      {
                      }).ToListAsync();
var firstlist=_financeContext.DeliveryDates.tolist();

var list = await (from d in firstlist
                  join p in _financeContext.Products on d.ProductId equals p.ProductId
                  select new
                          {
                          }).ToListAsync();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM