Using Entity Framework 5, the following code is invalid since I’m trying to cast a List<string> to List<TRK_USER>. Makes sense.
List<TRK_USER> userList = db.TRK_USER.Select(t => t.USER_FIRST).ToList();
However, I would like to maintain the type of the TRK_USER object. What I would hope/expect is that I could convert that List<string> to a List<TRK_USER> and just get nulls for all of the missing properties. So in this case I would have a List<TRK_USER> where only USER_FIRST is populated with data. Is this possible with some magical extension method?
Assuming that TRK_USER has a parameterless constructor, you could do:
But why would you want to do that?
would give the exact same information, just without unnecessary overhead.