I have that class:
public class Post
{
public Oid Id { get; private set; }
public IList<Comment> Comments { get; set; }
}
public class Comment
{
public Guid Id { get; set; }
public DateTime TimePosted { get; set; }
}
how in linq select that posts whose comments has e.g TimePosted >= DateTime.Now ??
Given a collection of
Postobjects called “posts“, you’d do something like this:Note that this is an example of Method syntax. For an example of Query syntax, see cybernate’s answer.
MSDN has a comparison of the two styles available here: LINQ Query Syntax versus Method Syntax.