need explanation about a linq query

T

Tony Johansson

Hello!

I just have some question about this linq query.
I have never used this into that is used in this query so I wonder what does
it do here ?
If this into was skipped here what would the difference be ?

var resultMappings =
from wsr in ccrFormObj.myWorksheetRowList
join wsrcm in ccrFormObj.commandMappingList
on wsr.ID equals wsrcm.WorksheetRowID
join wsrpm in ccrFormObj.parameterMappingList
on wsrcm.ID equals wsrpm.CommandMappingObjID
into gj
from subparam in gj.DefaultIfEmpty()
where wsr.WorksheetID == worksheetID
select new
{
wsrow = Convert.ToInt32(wsr.ID),
command = wsrcm.Name,
parametername = (subparam == null ? String.Empty :
subparam.Name)
};

//Tony
 
T

Tony Johansson

Hello!

Can you also explain what does it mean with this DefaultIfEmpty ?

//Tony
 
R

rhaazy

The into statement is inserting the results of the linq query into
temporary storage.
The DefaultEmpty is something that helps handle the case of null value
so you dont get an exception.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top