Why not just parse the DateTime
to your furthest desired precision (I'm assuming you want yyyy-MM-dd HH:mm:ss). And then compare them. I realize this is a bit long winded but an answer none-the-less.
DateTime dte1 = (DateTime)entity.secondDate;
DateTime dte2 = (DateTime)entity.firstDate;
if (DateTime.Compare(DateTime.ParseExact(dte1.ToString("yyyy-MM-dd HH:mm:ss"),
"yyyy-MM-dd HH:mm:ss",
null),
DateTime.ParseExact(dte2.ToString("yyyy-MM-dd HH:mm:ss"),
"yyyy-MM-dd HH:mm:ss",
null)) != 0)
{
throw new HttpRequestException(ExceptionMessages.CONCURRENCY_UPDATE);
}
Sorry for the bad formatting, just trying to minimize the horizontal scroll. This avoids the problem that the marked answer presents.