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; }
}
およびIは、(EF又はNHによって)このようなエンティティを照会:
var tagsAnon = _context.Tags
.Select(t => new { Tag = t, PostsCount = t. Posts.Count() })
.ToList();
今、どのようにしてtagsAnon
(アノ野外の物体)をTagModel
(例えば、 ICollection<TagModel>
またはIEnumerable<TagModel>
)?出来ますか?
はなぜ 'TagModel'に直接' Tag'をマッピングしていませんか?なぜ中間オブジェクトですか? –