Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var model = forumsDb.Categories
- .Select(c => new {c, c.Threads.Count})
- .ToList()
- public class Category
- {
- public int id {get;set;}
- public ICollection<Thread> Threads { get; set; }
- /***some properties***/
- [NotMapped]
- public int ThreadCount {get;set;}
- }
- public class YourModel
- {
- public YourModel(Category c, int count)
- {
- C = c;
- Count = count;
- c.Threads.Count = count;
- }
- public Category C { get; set; }
- public int Count { get; set; }
- }
- var model = forumsDb.Categories
- .Select(c => new YourModel(c, c.Threads.Count))
- .ToList()
- foreach(var entry in model)
- {
- entry.c.ThreadCount = entry.Count;
- }
- var categories = model.Select(m => m.c);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement