Lamda expression will not compile
- by John Soer
I am very confused
I have this lamba expression
tvPatientPrecriptionsEntities.Sort((p1, p2) =>
p1.MedicationStartDate.Value.CompareTo(p2.MedicationStartDate.Value));
Visual studio will not compile it and complains about syntax.
I converted the lamba expression to an anonymous delegate as so
tvPatientPrecriptionsEntities.Sort(
delegate(PatientPrecriptionsEntity p1, PatientPrecriptionsEntity p2)
{ return p1.MedicationStartDate.Value.CompareTo(p2.MedicationStartDate.Value); }
);
and it works fine.
The project is uses the .net 3.5 framework and I have a reference to system.linq.