C# Method to Compare DateTime Fields Specified During Execution?
C# Method to Compare DateTime Fields Specified During Execution? My project has many objects with date fields, and I often need to select everything where one such field is within a date range. For example: public class Contract { public DateTime SignDate { get; set; } public DateTime ReleaseDate { get; set; } } public class PersonalCheck { public DateTime SignDate { get; set; } public DateTime ProcessDate { get; set; } public DateTime VoidDate { get; set; } } If I only cared about SignDate, it would be easy. I would declare an Interface... public interface IObjectWithSignDate { DateTime SignDate { get; set; } } ...change my other objects to inherit from it, then create a method like this: public static IQueryable<T> SignedWithin<T>(this IQueryable<T> items, DateTime start, DateTime end) where T : IObjectWithSignDate { return items.Where(q => q.SignDate >= start && q.SignDate <= end); } How can I avoid rewr...
