score:2
(from a in Activities
join ov in OrganizationVolunteers on a.OrganizationID equals ov.OrganizationID
join av in ActivityVolunteers
on a.ActivityID equals av.VolunteerID into JoinedActVol
from av in JoinedActVol.DefaultIfEmpty()
where ov.VolunteerID==1
select new
{
a.ActivityID,
a.ActivityName,
av.ActivityRole,
a.OrganizationID,
OrganizationName = (from o in Organizations where o.OrganizationID == a.OrganizationID select o.OrganizationName).FirstOrDefault()
}).Union
(from a in Activities
join av in ActivityVolunteers on a.ActivityID equals av.ActivityID
where av.VolunteerID==1 && a.OrganizationID == null
select new
{
a.ActivityID,
a.ActivityName,
av.ActivityRole,
a.OrganizationID,
OrganizationName = ""
})
Source: stackoverflow.com
Related Articles
- Linq Join across three tables
- Inner Join on three tables using Linq
- Linq join three tables orderd by Timstamp
- How to join three tables and put it in a ViewModel using LINQ Lambda in ASP.Net MVC?
- LINQ Query to join three tables
- Looking for a better way to perform Left outer join on three tables in LINQ
- Linq Query with three tables join to send alert after x days
- Linq left outer join across multiple tables retrieving info from each table
- Join three tables using LINQ
- How to join three tables in linq with child table sum
- How to perform Join between multiple tables in LINQ lambda
- LINQ to SQL multiple tables left outer join
- Select All columns for all tables in join + linq join
- Joining three tables and using a left outer join
- How to join tables in EF LINQ
- How to join 3 tables with linq
- Linq group by multiple fields across different tables
- How to left join multiple tables with LINQ
- Join tables in SQLite.Net with LINQ on xamarin.android is not supported
- Multiple tables left join using Linq
- linq query to join two tables and get the count from one table values from the other
- Left outer join using LINQ -- understanding the code
- How to reuse a linq expression for 'Where' when using multiple source tables
- NHibernate 3 LINQ inner join issue with three jumps: NotSupportedException
- LINQ Source Code Available
- LINQ to Entities three table join query
- LINQ to SQL and Join two tables with OR clause
- Why do these three pieces of LINQ code produce different (or erroneous) results?
- using linq with join using two where on two tables
- linq join 3 tables with or condition
- How would I convert only a subset of column values from a DataRow into a string array using LINQ?
- Dynamic GroupBy using expression in .net core
- LINQ query to fetch bus number taking two records
- show one list inside another one list of Resful api.
- How to concatenate two columns in linq to sql query's select projection
- Linq to Entities, match where value contains one or more strings
- NHibernate Select N+1 with HasOne Mapping
- Linq to Sql : Overwrite properties while Joining tables
- Convert SQL to Dot Notion Linq
- Compare generic Collection?
- Linq query with many to many relations using entity framework
- Insert XML into an XML element
- LINQ: Compare two list based on their properties and return items that match certain conditions
- return list from linq function
- i want to update only single row column value with rollback commit
- Remove All from List where each line doesn't contain any item from another list
- How to execute Linq queries in Serenity
- What is the best way to transparently log changes to objects when using LINQ-to-SQL?
- How to get a list of filtered values in Dictionary into a List using LINQ or Lambda?
- How can I return all the columns of a table using multiple distinct columns in Linq