Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am doing this first time I got .edmx file in my project and imported function getallcompanies i am not getting how to call a storedproc in webapi . can any one please help me am trying this from morning . this is my webapi controller

public class CompanyServiceController : ApiController
{
private PTMEntities db = new PTMEntities();
public IEnumerable<Company> GetAllCompanies()
{

using (var db = new PTMEntities())
{

return db.GetAllCompanies();
}

}

i am totally confused with Interface repository is there in some sites and not there in somesites.

And in model1.contect.cs i have this with error

public virtual ObjectResult<GetAllCompanies_Result> GetAllCompanies()
{
return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<GetAllCompanies_Result>("GetAllCompanies");
}
}

and i got Model.tt which has

GetAllCompanies_Result.cs
Posted

1 solution

Hello

in edmx table(entitys) and sp have there own cs files.
SO when you have sp in edmx and you get it on Model.tt then you used like this:-


public IEnumerable<GetAllCompanies_Result> GetAllCompanies()
{
 
using (var db = new PTMEntities())
{
 
return db.GetAllCompanies();
}
 
}


here you return type is
GetAllCompanies_Result

not company thats why you not return and get error.
I hope you problem will resolve
 
Share this answer
 
Comments
karthik mushyam 15-Jan-14 23:52pm    
Thanq u rizwan muhammed khan gouri

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