c# - Linq query with group by retrieving percentage -
i have calculate percentage in group clause. more in depth need calculate percentage of controlforms have status = 'false'. status in table checkresult.
var items = (from controlform in datacontext.controlforms join controlformstatus in datacontext.controlformstatus on controlform.fk_controlformstatus equals controlformstatus.id join doccheck in datacontext.documentchecks on controlform.id equals doccheck.fk_controlform join checkresult in datacontext.checkresults on doccheck.fk_checkresult equals checkresult.id controlform.fk_controlcycle.tostring().equals(controlcycleid) & ( controlformstatus.description.equals(constants.controlformstatustestcontrolowner) | controlformstatus.description.equals(constants.controlformstatusapprovalprocessowner)) group controlform new { controlform.id, controlform.fk_controlcycle, controlform.fk_samplenode, controlform.fk_control, /*function*/} ctrlform select new controlformreportpartialresults(ctrlform.key.id, ctrlform.key.fk_controlcycle, ctrlform.key.fk_samplenode, ctrlform.key.fk_control, valuefunction));
can suggest me have istead of /function/? or if there way solve problem? welcome!
thanks in advance, dario zanelli
replace "collection" appropriate variable containing items want calculate percentage for:
collection.select(item => item.status == false).count() / collection.count() * 100
Comments
Post a Comment