score:8
Accepted answer
you're currently doing an inner join, but you can use defaultifempty() to create a left outer join. this will also return the null records.
var resulttable = from m in messages
join i in images on m.imageid equals i.imageid into imgjoin
from img in imgjoin.defaultifempty()
select new
{
messageid = m.messageid,
timestamp = m.timestamp,
text = m.text,
roomid = m.roomid,
imageid = m.imageid,
userid = m.userid,
path = img != null ? img.path : ""
};
Source: stackoverflow.com
Related Query
- Joining two tables with LINQ while also returning null records from the second table
- Joining two tables and returning multiple records as one row using LINQ
- How can I make a JOIN query with LINQ between two tables (entities) with many-to-many relationship, while there is no joining table in EF?
- How to get NULL from LINQ When no value found in the joining tables
- LINQ Joining Two Tables and Getting the Row with Max ID
- How to get data from two tables but with where clause on the second (FOREIGN KEY) table? [LINQ]
- LINQ - joining two tables and getting the values from the right part of the join if it exists throw exception
- Left join on two Lists and maintain one property from the right with Linq
- Access all of the data after joining two tables and group them using linq
- linq query to join two tables and get the count from one table values from the other
- LINQ Union between two tables with the same fields and then returned in a collection
- Linq full outer join with NULL records C# from datatables
- I'm trying to simplify with linq a statement that takes 2 lists of numbers and subtracts the first one from the second one
- Linq Query to Get Distinct Records from Two Tables
- LINQ Query To Join Two Tables and Select Most Recent Records from Table B corresponding to Table A
- Combining two datatable and getting the amount from second table by using linq
- What's the best way to copy and insert data from related tables into a new set of related tables with Linq
- Get first value from table with where either have the value match or null with LINQ
- Returning the result from a linq query but with one value modified
- How to merge two lists while adding metadata indicating value source with LINQ statement?
- How to join two tables using Linq and count the rows of one column matched records
- Getting records from many to many relationship with their order in the joining table using EF?
- LINQ - joining two tables and geting the result in a viewmodel that has a different structure
- LINQ - Get records from one table, with second table multi record matching
- Use LINQ to compare two lists, and produce a third one with results from one OR the other
- Return type for Linq query Joining two tables from a Data Access Layer
- MVC3 Linq updating two tables with data from one model
- way to go from list of objects to SortedList<string,string> with two of the fields using LINQ
- Array.copy two lambdas, difficult with using the second in linq
- Get selected records in linq union from two different tables
More Query from same tag
- How to Return Extra Data with IQueryable method?
- Using linq to combine objects
- Help with Linq query, need to set ID based on results of a sub-query
- Use linq to return a selection of data from list<t>
- LINQBridge users: is it feature-complete?
- WPF LINQ query result as percentage
- Best way to implement extension methods
- PLINQ not improving the performance
- Python: LINQ capable class supporting simultaneously laziness and fluent design
- LINQ on datatable to sum multiple columns vb.net
- How can I have a LINQ where clause that does nothing?
- Join datatable in c# with null objects
- How can I stop intellisense from auto completing 'from' when typing linq query
- Grouping list items by class property proximity from each other with some threshold
- C# get distinct and max value
- OrderBy().Last() or OrderByDescending().First() performance
- Creating LINQ query with two parameters
- How to remove Distinct values from a list?
- F# Power Pack Linq Issue
- LINQ to XML: parsing XML file which one of nodes presents type of another node
- linq condition in select statement
- T-SQL to LINQ Query (Many to Many filter)
- TSQL equivalent of Linq SelectMany
- How to remove null datarow from datatable except Autoincrement column
- Querying a junction table using EF Core
- Algorithm to calculate nearest location based on longitude & latitude
- XDocument to Dictionary
- about return type in linq
- How to use method-based queries with lambda expressions
- How to use linq to parse xml file?