I have classes
public class BlogPost
{
public int Id {get;set;}
public string Body{get;set;}
public IList<Comment> Comments{get;set;}
//other properties
}
public class Comment
{
public int Id {get;set;}
public int TypeId {get;set;}
public int BlogPostId {get;set;}
public DateTime DateAdd {get;set;}
public string Body {get;set;}
//other properties
}
So we have some collection of BlogPost where each BlogPost can have many Comments.
I would like to get collection of all BlogPosts where last Comment (this with MAX(DateAdde) is with TypeId=1 or TypeId=2. Thanks in advance.
I did my best to transpose your class structure into a query I have doing something along the same lines. Mine was after 1 parent with criteria that has a child where the newest child had special criteria. I removed the parent criteria and applied your class structure, so it should be close, but untested.