Entity Framework Error: Cannot implicitly convert type IQueryable<AnonymousType#1> to ClassifiedV2.Models.ad

Last Reply 6 days ago By dharmendr

Posted 6 days ago

hello,

i have one field is int and another field is Bigint i want to apply joining condition how to cast please advice?

ad AdsObj = (from  objads in db.ads
             join objbrand in db.brands on Convert.ToInt32(objads.brandId) equals objbrand.id
             select new ad
             {
 
             });

following errors come

Cannot implicitly convert type 'System.Linq.IQueryable<AnonymousType#1>' to 'ClassifiedV2.Models.ad'. An explicit conversion exists (are you missing a cast?) D:\Projects\ClassifiedV2\ClassifiedV2\Controllers\AdsController.cs  605 30  ClassifiedV2

Posted 6 days ago

Problem is in the select section of the query.

ad AdsObj = (from  objads in db.ads
             join objbrand in db.brands on Convert.ToInt64(objads.brandId) equals Convert.ToInt64(objbrand.id)
             select new ad
             {
                 // Assign value to your model properties.
             });