I have a list< item > of the following
public class Item
{
public string Link { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public DateTime PublishDate { get; set; }
public FeedType FeedType { get; set; }
public Item()
{
Link = "";
Title = "";
Content = "";
PublishDate = DateTime.Today;
FeedType = FeedType.RSS;
}
}
Which is just a parsed RSS feed, I now want to be able to query the List< item > to pull out items only with a PublishDate of today?
However I'm getting a bit lost... Can anyone shed any light please?
If I understand correctly the goal here is to strip off the time when comparing.
Extention Method syntax
var today = DateTime.Today;
items.Where( item => item.PublishDate.Date == today );
Query syntax
var today = DateTime.Today;
from item in items
where item.PublishDate.Date == Today
select item
DateTime today = DateTime.Today;
var todayItems = list.Where(item => item.PublishDate.Date == today);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With