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
Post a Comment