(cn.PublishEnd == null || cn.PublishEnd < DateTime.Now)
vs
(cn.PublishEnd ?? DateTime.MinValue < DateTime.Now)
Which is more readable? I'm inclined towards the second form, but something tells me I'm wrong.
Context:
namespace Damnation.Website.Main.Business.Extensions
{
public static class CommunityNews
{
public static IEnumerable<DAL.CommunityNews> Published(this ObjectSet<DAL.CommunityNews> table)
{
return table.Where(cn => cn.PublishStart > DateTime.Now && DateTime.Now > (cn.PublishEnd ?? DateTime.MinValue)).OrderByDescending(cn => cn.PublishStart);
}
}
}
Types
DateTime PublishStart
DateTime? PublishEnd
cn.PublishEnd
? If it happened to be of typebool?
(very odd), then that would invalidate my answer and would need clarification. Is this going to be a part of a conditional and you use the value somewhere? Other things will change as well in that case. \$\endgroup\$ – Jeff Mercado Aug 21 '11 at 18:45DateTime?
, I'll update with the full snippet. \$\endgroup\$ – bevacqua Aug 21 '11 at 18:50