I assumed Article
class looks like that:
Public Class Article
Public Property Dated as DateTime?
End Class
You should get DateTime?
from database using EF, and then perform ToShortDateString
as LINQ to Objects query. EF won't be able to translate ToShortDateString
to proper SQL.
Dim query = From x In context.Languages
Order By x.Name
Select New With {
.Name = x.Name,
.LastArticleDate = x.Articles.OrderByDescending(Function(x) x.Dated).FirstOrDefault()
}
Dim results = From x In query.AsEnumerable()
Select New MyViewModel() With {
.Name = x.Name,
.LastArticleDate = If(!x.LastArticleDate.HasValue, "", x.LastArticleDate.ToShortDateString())
}