[英]Getting error -> System.Linq.Enumerable+WhereSelectListIterator`2[Tdsb.Aris.Pims.Entity.PartnershipFunding,System.String]
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;
}
}
receiving error like -> 收到类似->的错误
System.Linq.Enumerable+WhereSelectListIterator`2[Tdsb.Aris.Pims.Entity.PartnershipFunding,System.String]
System.Linq.Enumerable + WhereSelectListIterator`2 [Tdsb.Aris.Pims.Entity.PartnershipFunding,System.String]
Your question suggests an error, but the value seems to be the type name that is pushed into paidBy
string
: 您的问题表明有一个错误,但该值似乎是被推送到
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
I think you should have something like this: 我想你应该有这样的东西:
paidBy = PartnershipFundingEntity
.Where(x => x.FundingTypeId == 1)
.First(x => <boolean condition to select one element>)
.PaidByProp;
This works if a single element is found, otherwise FirstOrDefault
should be used and tested for null. 如果找到单个元素,则此方法有效,否则应使用
FirstOrDefault
并测试其为null。 I think ?.
我认为
?.
(null conditional) can be used to narrow to a single instruction. (空条件)可用于缩小到一条指令。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.