c# - Cannot convert from IQueryable <decimal,Project1,Model> to IQueryable<Project1,Model> -


what error mean?

my error is:

cannot implicitly convert type 'system.linq.iqueryable<system.linq.igrouping<decimal,project1.domain.models.departmentbreakdownreport>>' 'system.linq.iqueryable<project1.domain.models.departmentbreakdownreport>'. explicit conversion exists (are missing cast?) 

i know in order me able fix it. happens when add linq groupby onto results.

 public iqueryable<departmentbreakdownreport> getdepartmentbreakdownbysupplieridandreviewid(int clientid, int? supplierid, int? reviewid) {             return (from d in db.details                     join h in db.headers                     on new { d.clientid, d.claimid }                     equals new { h.clientid, h.claimid }                     d.clientid == clientid && h.supplierid == supplierid                      join sd in db.suppdepts                     on new { = d.clientid, b = d.categoryid ?? 0 }                     equals new { = sd.clientid, b = sd.categoryid }                      join r in db.reviews                     on new { h.clientid, h.reviewid }                     equals new { r.clientid, r.reviewid }                      join rp in db.reviewperiods                     on new { = r.clientid, b = r.reviewperiodid ?? 0 }                     equals new { = rp.clientid, b = rp.reviewperiodid }                     r.reviewid == reviewid                      join su in db.suppliers                    on new { h.clientid, h.supplierid }                equals new { su.clientid, su.supplierid }                      select new departmentbreakdownreport {                         departmentname = sd.departmentname,                         sumofamount = d.amount,                         supplierid = h.supplierid,                         reviewid = h.reviewid,                         reviewname = rp.reviewperiodname,                         suppliername = su.suppliername,                         clientid = d.clientid                     }).groupby(r=>r.amount);         } 

what error mean?

your return type iqueryable<departmentbreakdownreport> yet attempting return igrouping<decimal,project1.domain.models.departmentbreakdownreport>

when call .groupby change return type igrouping rather iqueryable, introduces decimal part of igrouping expression (which amount variable grouping by).

to fix can change method signature to:

public igrouping<decimal,project1.domain.models.departmentbreakdownreport> getdepartmentbreakdownbysupplieridandreviewid(int clientid, int? supplierid, int? reviewid) 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -