Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

when i started the program i get error from query

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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()

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading