c# - Selecting list of object type after grouping in linq -


i have table such following:

productid, categoryid
123, category1
123, category2
123, category1

my parameter productid , need return list of type category based on distinct categories given productid in above table.

you leverage .distinct() function linq select distinct categories belonging specified productid.

var plist = (from p in context.products  p.productid == productid  select p.category).distinct().tolist(); 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -