【发布时间】:2011-09-30 17:41:22
【问题描述】:
这里是我写的代码,一旦我添加了调用第二个函数ValidCodes = GetValidCodes(bv.Variable_Id)的行,我就会收到错误
public IQueryable<BvIndexRow> GetBenefitVariableIndex(int healthPlanId)
{
var q = from bv in Db.BenefitVariables
where bv.Private == "N" || (bv.Private == "Y" && bv.Health_Plan_ID == healthPlanId)
join bao in Db.baObject on bv.Variable_Id equals bao.ba_Object_id
join servicetype in Db.BenefitVariableServiceTypes.Where(bvst => bvst.Key_Service_Type == "Y" && bvst.isActive == 1)
on bv.Variable_Id equals servicetype.Variable_Id into groupedBvst
where bv.isActive == 1 && bao.isActive == 1
from bvst in groupedBvst.DefaultIfEmpty()
select new BvIndexRow
{
// some code here too
ValidCodes = GetValidCodes(bv.Variable_Id)
};
return q;
}
public string GetValidCodes(int varID)
{
// some code here
return "None";
}
【问题讨论】:
-
您遇到什么错误?您能否以更易读的格式重新发布代码,去掉与问题无关的行?
-
我不知道为什么我的问题得到了 -ve 票。请大家理解并及时回复。
-
@NetDev 我也不确定你为什么这样做,我今天显然已经投票了很多并且已经达到了我的极限,但我会尝试消除其他人的鲁莽。我认为这是由于格式(您已修复)。您提出的问题涉及 LINQ-to-SQL 的基本部分,新手很容易忽略该部分。我当然认为它很有用!
标签: c# linq linq-to-sql generics