使用entityframework通过Webapi中的storedProc获取数据 [英] Getting Data through storedProc in Webapi using entityframework
本文介绍了使用entityframework通过Webapi中的storedProc获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
收到错误:无法隐式转换类型'system.data.objects.objectresult到system.collections.generic.IEnumarable
Web Api控制器代码
Am getting error :cannot implicitly convert type 'system.data.objects.objectresult to system.collections.generic.IEnumarable
Web Api Controller code
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");
}
推荐答案
试试这个..
Try this..
return db.GetAllCompanies().AsEnumerable<getallcompanies_result>();
return db.GetAllCompanies();
这篇关于使用entityframework通过Webapi中的storedProc获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文