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

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -