need explanation about a linq query

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
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
 
Hello!

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

//Tony
 
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.
 
Back
Top