c# - Cannot Group By on multiple columns and Count -


i want write simple query linq:

select issuercode,securitycode,dataprocessingflag,count(issuercode) cnt  cmr_invhdr processedlike <> 'stmnt only' group issuercode,securitycode,dataprocessingflag order issuercode 

i've tried following code error( dbexpressionbinding requires input expression collection resulttype. parameter name: input) :

 var lstcmrinvhdrnips = (from r in e.cmr_invhdr                          r.processedlike != "stmnt only"                          select new {                                          r.issuercode,                                          r.securitycode,                                          countofissuercode = r.issuercode.count(),                                         r.dataprocessingflag                                      }                          ).groupby(x =>                                         new {                                                 x.issuercode,                                                 x.securitycode,                                                 x.dataprocessingflag,                                                 x.countofissuercode                                             }                                    ).orderby(x => x.key.issuercode).tolist(); 

is there sense count issuercode while grouping field @ once? when groupped field, it's count 1.

probably should not group issuercode , count after groupby in separate select statement:

var result = e.cmr_invhdr               .where(r => r.processedlike != "stmnt only")               .groupby(r => new { r.securitycode, r.dataprocessingflag })               .select(r => new                {                    value = r.key,                    issuercodescount = r.groupby(g => g.issuercode).count()                })               .tolist(); 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -