c# - Linq Projecting from one type to a second using fluent syntax -
I have an EF table / object that I want to map to a new object which is almost identical. I could use Automaker but it was hoping to do with Linq projection. I am using this code to create a list of objects.
var ci = db.Incidents Where (a => a.FollowUpDate.Value.Year == DateTime.Now.Year & amp; a.FollowUpDate.Value.Month == DateTime.Now.Month) .Oolist ();
What problems are coming in my understanding of using projection to convert events into developments?
You can project your results on a query from your class object. Assume that your class name is MyClass
, you can do it:
var ci = db.Incidents. Where (a = & gt; a.FollowUpDate.Value.Year == date time.N. year and amp; a.FollowUpDate.Value.Month == DateTime.Now.Month). Select (R = & gt; New MyClass {property1 = r.Property1, // Properties of the rest .....}). To create the list ();
Comments
Post a Comment