What's the difference b/w select and select new in linq.
var SelectNew = from L1 in liStudent select new { L1.Name, L1.ID };
var SelectNew2 = from L2 in liStudent select L2;
Your first one, SelectNew
is returning an enumerable of anonymous types with two properties, Name
and ID
, whereas SelectNew2
is returning an enumerable of iiStudent
entities. You'd use the first instance when you need to return a subset of the data available in the entity/model.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With