score:0
in this case it's much easier to do the join in the anonymous type:
from component in materials.oftype<container>().where(m => m.active)
select new
{
id = component.id,
name = component.name,
subtype = component.subtype,
size = component.size,
materialids = component.materials.select(x => x.id),
brandnames = component.brands.select(x => x.name),
segmentratings = (from segmentfinancerating in segmentfinanceratingview
where segmentfinancerating.materialid == component.id
select segmentfinancerating)
}
you will have an empty collection of segmentratings
when there are none for a specific component, giving the same effect as outer join.
score:1
groupby in list doesn't work for you?
var list = (from component in materials.oftype<container>().where(m => m.active)
join segmentfinancerating in segmentfinanceratingview on component.id equals segmentfinancerating.materialid into segmentfinanceratinggroup
from segmentfinanceratingwithdefault in segmentfinanceratinggroup.defaultifempty()
select new
{
id = component.id,
name = component.name,
subtype = component.subtype,
size = component.size,
materialids = component.materials.select(x => x.id),
brandnames = component.brands.select(x => x.name),
segmentratings = segmentfinanceratingwithdefault
}).tolist().groupby(s=> s.segmentratings);
Source: stackoverflow.com
Related Query
- Linq to Entities Left outer join grouped into a collection
- Left outer join using LINQ -- understanding the code
- EF Linq to Entities calling ToList() on entity set generates SQL command containing multiple left outer join
- How to add left outer join to grouped and summed LINQ query
- Left Outer Join in Linq to Entities / SQL
- Convert simple Left Outer Join and group by SQL statement into Linq
- Aggregate functions with a left outer join in LINQ to Entities
- Converting SQL to LINQ (inner join into a left outer join) C#
- linq to entities left outer join
- Left Outer join LINQ query with four entities in CRM 2011 and with multiple where clauses
- Left outer join in Linq To Entities (The entity or complex type cannot be constructed in a LINQ to Entities query.)
- Linq to entities - One to many relationship - need left outer join instead of cross join
- Left Outer Join LINQ To Entities
- Left outer join Linq to Entities with MVC model
- Using multiple LINQ statements with into , for the DefaultIfEmpty() of the left outer join not working
- how to convert a sql query into linq LEFT OUTER JOIN
- LEFT OUTER JOIN in LINQ
- How do you perform a left outer join using linq extension methods
- LINQ to SQL - Left Outer Join with multiple join conditions
- LINQ to SQL Left Outer Join
- LINQ to SQL multiple tables left outer join
- How to limit a LINQ left outer join to one row
- left outer join in lambda/method syntax in Linq
- Extension method for IQueryable left outer join using LINQ
- Linq - Left outer join with dot notation
- LINQ left outer join query error: OuterApply did not have the appropriate keys
- Linq left outer join with custom comparator
- Left join after a into group in Linq using entity framework (core)
- Outer join query using LINQ to Entities
- Linq Left Outer Join - DefaultIfEmpty Error
More Query from same tag
- Make a copy of a Datatable with some changes
- What could cause a "This may indicate either a bug or a limitation in EF Core." error in a linq expression .net core 3.0?
- Linq like for Java
- Sorting a DataTable by columns in a file
- Distinct in LINQ and change result type
- Entity Framework Error - The cast to value type 'System.Int64' failed because the materialized value is null
- How to select each splited string and group by with another members in linq?
- Cannot initialize type 'SelectListItem' with a collection initializer because it does not implement 'System.Collections.IEnumerable'
- How to join unknown number of lists in LINQ
- Why does this LINQ throw "FormatException was unhandled"?
- How to convert a 'Y' or 'N' Value to a boolean value using linq?
- Linq query within a date range on several tables?
- Get Unique Elements from the List based on Element Property
- Get the index of item in list based on value
- How to optimize a LINQ with minimum and additional condition
- Search query using .Contains() for parameters that combine two columns
- How to convert XML to Dictionary
- ASP.net Core C# Linq Distinct not working
- Sort a GridView thats bound to a Linq query
- Mongodb c# driver: view MQL bson query generated from linq
- Optimized code for Insert and Update in one method with LINQ?
- LINQ search in 2d array by word
- Compare keys of dictionary with values of List and return all the matching values including duplicates
- Get items from nested list
- Get list of Users with Roles without DBContext in asp.net mvc
- LINQ optional where clause
- Find the intersection of two lists using the RavenDB 4 LINQ provider
- Is there a way to set values in LINQ?
- Does Linq OrderBy Not Sort Original Collection?
- linq operators like in