Home > Back-end >  when i started the program i get error from query
when i started the program i get error from query

Time:12-22

Hi i develop web app with c# and swagger. i have problem. why i took this exception ?

public AsiCovidDto GetAsiCovid()
{
    using(SirketDBContext context=new SirketDBContext())
    {
        var query = 
            from c in context.Covids
            group c by 1 into g
            select new AsiCovidDto
            {
                AsiCovidOrani = g.Sum(x => x.AsiDurumu == "1" ? 1 : 0) / g.Max(x => x.CovidId)

            };
        //exception  return (AsiCovidDto)query;
    }
}

exception

enter image description here

CodePudding user response:

Right now you just have the result object (an IQueryable<T>), as your exception states.

This doesnt provide a cast as to the desired type. What you need to do is to extract your object from IQueryable<T> via query.First()

  • Related