Hi guys!
Going to need your help on this one.
I'm trying to OrderBy first reply datetime if present. If it's empty/null, it must order by topic datetime. I've ended up with the following expression, but it just doesn't seem to work :(
return db.Topics
.Where(t => t.ForumID == id)
.OrderBy(
t => t.Replies
.OrderBy(r => r.AddDatetime.Equals(System.Data.SqlTypes.SqlDateTime.Null.Value) ? t.AddDatetime : r.AddDatetime)
.Select(r => r.AddDatetime)
.First()
);