实体框架单个结果ObjectResult

时间:2010-11-28 15:55:51

标签: c# .net asp.net entity-framework entity-framework-4

我有一个总是返回单行的存储过程 目前我的代码看起来像这样

public void DoSomthing()
{
    ObjectResult<pDoesProductExist_Result> pDoesProductExistResults = tbsDBEntities.pDoesProductExist(itemCode);
                foreach (pDoesProductExist_Result pDoesProductExistResult in pDoesProductExistResults)
                {
                   return;
                }
...
}

有更好的方法吗?

1 个答案:

答案 0 :(得分:2)

pDoesProductExist_Result exists = tbsDBEntities.pDoesProductExist(itemCode).Single();