Как использовать Automapper для проецирования Blog
в BlogListItemDto
, но без свойства навигации?
например
public class Blog
{
public int Id{get;set;}
public string Title{get;set;}
//public IList<Post> Posts{get;set;} with out this properties
}
public class Post
{
public int Id{get;set;}
public int BlogId {get;set;}
public Blog Blog{get;set;}
...
}
// and here's the dto
public class BlogListItemDto
{
public int Id{get;set;}
public string Title{get;set;}
public int PostCount{get;et;} // how I get this property to project
}
Я могу сделать это без автомпера db.Blog.Select(b=>new BlogListTiemDto{ Id=b.Id,Title = b.Title, PostCount = db.Post.Where(p=>p.BlogId == b.Id).Count() })