Click here to Skip to main content
15,898,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Am getting error :cannot implicitly convert type 'system.data.objects.objectresult to system.collections.generic.IEnumarable

Web Api Controller code

C#
private PTMEntities db = new PTMEntities();

    public IEnumerable<GetAllCompanies_Result> GetAllCompanies()
    {

        using (var db = new PTMEntities())
        {
            return db.GetAllCompanies();
        }
    }

Model1.context.cs code here

 public virtual ObjectResult<GetAllCompanies_Result> GetAllCompanies()
    {
        return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<GetAllCompanies_Result>("GetAllCompanies");
    }
Posted
Updated 15-Jan-14 22:10pm
v2

1 solution

Try this..


C#
return db.GetAllCompanies().AsEnumerable<getallcompanies_result>(); 


return db.GetAllCompanies();
 
Share this answer
 
v2
Comments
karthik mushyam 16-Jan-14 4:58am    
Am not even getting any intellisence after GetAllCompanies..
Here am using Entityframework 6.0.0.0 and also am getting error u have to add reference EF 4.0.0.0 –
karthik mushyam 16-Jan-14 4:58am    
I have this in mvcproject web.config
and in packages in .edmx folder i have <packages> <package id="EntityFramework" version="5.0.0" targetFramework="net45"
Karthik_Mahalingam 16-Jan-14 5:04am    
ok can u tell me the type of object ? which you are getting from db.Getallcompanies ();
karthik mushyam 16-Jan-14 5:28am    
I got it i overall upgraded my visulstudio to EF6.0.0.0
Karthik_Mahalingam 16-Jan-14 5:30am    
your issue solved?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900