У меня есть объект:
public class Tag {
public int Id { get; set; }
public string Word { get; set; }
// other properties...
// and a collection of blogposts:
public ICollection<Post> Posts { get; set; }
}
и модель:
public class TagModel {
public int Id { get; set; }
public string Word { get; set; }
// other properties...
// and a collection of blogposts:
public int PostsCount { get; set; }
}
, и я запрашиваю объект следующим образом (от EFили NH):
var tagsAnon = _context.Tags
.Select(t => new { Tag = t, PostsCount = t. Posts.Count() })
.ToList();
Теперь, как я могу отобразить tagsAnon
(как анонимный объект) в набор TagModel
(например, ICollection
или IEnumerable
)? Это возможно?