C# linq dates between -
I am tring to get a list of dates from my db which will eventually be used to populate a calendar Each 'Calendar Event' has a start date & amp; End date, all dates & amp; Start & amp;
Public listing & lt; EventFeed & gt; GetCalendarDates () {Return (from event list in getEventsList) select new EventFeed () {// EventDate = todo}). ToList (); }
UPDATE
Just to be clear, if I have a calendar event called Fobors which starts on 22/08/2010 and 24 / 08/2010, then I should return my list:
22/08/2010, 23/08/2010, 24/08/2010
Thank you KB < / P>
I had to do something like this, I had to do Func & lt; & Gt;
used the resulting linq query.
I've added the same Func
for your Linq query, if you did not specify the name of the returned object by the GetEventsList ()
, then the function's Type
Public Stable List & amp; Lt; Event Feeds & gt; GetCalendarDates () {Func & lt; EventItem, list & lt; DateTime & gt; & Gt; ExtractEventDates = eventItem = & gt; {Var date = new list & lt; DateTime & gt; (); (Var date = eventItem.StartDate; date & lt; = eventItem.EndDate; date = date.AddDays (1)) {dates.Add (date); } Return dates; }; Select the eventDate (eventItem) New EventFeed {EventDate = eventDate} in the extractEventDates (return to GetEventsList (from EventEtem)). ToList (); }
Comments
Post a Comment