c# - Find distinct column id and column count with condition -
i have table bookorder_t columns follows orderid,bookid, ordersuccess . want find bookids ordersuccess= 1, , count of book ids.
suppose bookorder_t
orderid bookid ordersuccess ---------------------------- 100 1 1 101 1 null 102 1 1 103 2 1 104 2 1 106 1 1
my expected result is
bookid count 1 3 2 2
how write query in in linq?
this should give correct result:-
var result = db.bookorder_t.where(x => x.ordersuccess == 1) .groupby(x => x.bookid) .select(x => new { bookid = x.key, count = x.count() });
Comments
Post a Comment