I am using EF4 and I need to make this query with LINQ, but I don't know how to do it.
If I have 3 tables:
ProductType → one-to-many → Product → many-to-one → Season
I would like to have a list of all ProductType with their products in one season. Please note that I need to list ALL ProductType , even if there is no product this season.
Thank you for your help!
Assuming you need a left join, according to your question, do:
var query = from pt in model.ProductTypes select new { ProductType = pt, Products = from p in pt.Products where p.SeasonId == seasonId select p };
:
var query = from pt in model.ProductTypes join p in model.Product.Where(p => p.SeasonId == seasonId) on pt.Id equals p.ProductTypeId into g select new { ProductType = pt, Products = g };
, join ... into, , , .
join ... into
Source: https://habr.com/ru/post/1758222/More articles:Javascript local variable works like a class variable in a window - javascriptКак удалить существующую функцию javascript для кнопки - jqueryPlease view my design - Need Input - designHibernate Auto Increment - javajqgrid resizable - jqueryProblems with time.sleep and multithreading in Python - pythonPetclinic spring -mvc building example - springhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1758225/netbeans-needs-to-be-compiled-badge&usg=ALkJrhiwk0f4OwZzN6pYWdffpCIAIs-j-wCan I create a predicate that will take both functions and functors as a parameter? - c ++Card Manipulation - phpAll Articles