c# - List only categories that have products -
i have database following structure:
categories
[pk]catid
catname
producttypes
[pk]typeid
typename
manufacturer
manufacturerid
name
products
[pk]prodid
title
typeid
manufacturerid
isdeleted (bool)
ishidden (bool)
producttypes "irrelevant" application, necessary export system.
i want nested list categories , products filtered on products.isdeleted , products.ishidden this
category 1
product.prodid - product.title, manufacturer.name ...
category 2
product.prodid - product.title, manufacturer.name ...
how in simplest way ef
var catlist = db.typeids.where(t => t.product.count() > 0).select(x => x.typecat).distinct().tolist(); this gives me categories, no filtering deleted/hidden products
instead of
.where(t => t.product.count() > 0) use
.where(t => t.product.any(u => !u.ishidden && !u.isdeleted))
Comments
Post a Comment