c# - asp.net MVC how to show chlid count of model -


i have model named productgroup , want show count of child product group in view .

enter image description here

that's pretty simple linq query:

var productchildcounts = context.productgroups                 .include(pg => pg.products)                 .include(pg => pg.attributes)                 .select(pg => new                 {                     pg.title,                     productcount = pg.products.count(),                     attributecount = pg.attributes.count()                 }); 

http://www.dotnetcurry.com/showarticle.aspx?id=513


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -