Can I join a list object in a .NET collection with an enity object in EF

Can I join a list object in a .net collection with an enity object in EF like

   var prodts = from req in Product
               join prod in context.ProductApplications on req.ProductGUID equals prod.ProductGUID 
              slect req;

A product is an lsit object. and context.ProductApplications is an Enity object.

May I join them, can someone please let me know how to join them.

+3
source share
1 answer

You can do it, yes. Alternative chain syntax:

var prodts = Product.
             Join(
                  context.ProductApplications,
                  req => req.ProductGUID,
                  prod => prod.ProductGUID,
                  (req, prod) => req
                 );

IEnumerable<Product>. Join IEnumerable<> , , DB , context.ProductApplications , . "" Product.

GUIDs Product(s?), context.ProductApplications, "" GUIDs ( , ). join.

var prodts = context.
             ProductApplications.
             Where(pa => Product.
                         Select(p => p.ProductGUID).
                         Contains(pa.ProductGUID)
                  );
+3

Source: https://habr.com/ru/post/1759069/


All Articles