I'm trying to run this simple query:
var appt = (from a in context.AppointmentSet
select new Appointment{ ModifiedOn = a.ModifiedOn}).First();
but I'm getting a compiler exception since ModifiedOn is readonly.
- I could just return
a
, but then all the attributes of theAppointment
entity will be returned, not just theModifiedOn
. - I could return
new { a.ModifiedOn }
, but then appt would be anAnonymousType
and not anAppointment
.
What's the suggested way to make this work?
Note, this is an example, assume that I'm returning more than just a single property from Appointment, and then there is a where criteria of some sort