C# LINQ question, Why need new here?
- by 5YrsLaterDBA
Why we need the new in the select statement on one of them?
var runs = from sampleDataTable in db.SampleData
from sampleInfoTable in db.SampleInfo
where sampleDataTable.SampleInfo.SampleInfoId == sampleInfoTable.SampleInfoId
select new {sampleDataTable.Timestamp, sampleDataTable.SampleDataId, sampleInfoTable.Lane} ;
and
var runs2 = from sampleDataTable in db.SampleData
from sampleInfoTable in db.SampleInfo
where sampleDataTable.SampleInfo.SampleInfoId == sampleInfoTable.SampleInfoId
&& sampleDataTable.Timestamp == timestamp
select sampleInfoTable.Lane;