Choose vs Choose new in linq

What is 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;
+5
source share
1 answer

Your first one SelectNewreturns an enumerated type of anonymous types with two properties, Nameand IDwhile it SelectNew2returns an enumerated object iiStudent. You should use the first instance when you need to return a subset of the data available in the object / model.

+11
source

All Articles