private string Paidby
{
get
{
string paidBy = string.Empty;
if(this.PartnershipFundingEntity!=null)
{
paidBy = (PartnershipFundingEntity.Where(x => x.FundingTypeId == 1).Select(y => y.CfPurposeList)).ToString();
}
return paidBy;
}
}
收到错误,如 - >
System.Linq.Enumerable + WhereSelectListIterator`2 [Tdsb.Aris.Pims.Entity.PartnershipFunding,System.String]
答案 0 :(得分:1)
您的问题提示错误,但值似乎是推入paidBy
string
的类型名称:
paidBy = (PartnershipFundingEntity
.Where(x => x.FundingTypeId == 1) // where iterator at this point
.Select(y => y.CfPurposeList)) // WhereSelectListIterator at this point
.ToString(); // ToString() returns type name by default
我认为你应该有这样的事情:
paidBy = PartnershipFundingEntity
.Where(x => x.FundingTypeId == 1)
.First(x => <boolean condition to select one element>)
.PaidByProp;
如果找到单个元素,则此方法有效,否则应使用FirstOrDefault
并测试null。我认为?.
(null条件)可用于缩小到单个指令。