简体   繁体   English

出现错误-> System.Linq.Enumerable + WhereSelectListIterator`2 [Tdsb.Aris.Pims.Entity.PartnershipFunding,System.String]

[英]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.

相关问题 System.Linq.Enumerable + WhereSelectListIterator`2 - System.Linq.Enumerable+WhereSelectListIterator`2 LINQ foreach循环中的System.Linq.Enumerable + d__3a`1 [System.String]错误 - System.Linq.Enumerable+d__3a`1[System.String] error in LINQ foreach loop System.Linq.Enumerable.WhereListIterator和System.Linq.Enumerable.WhereSelectListIterator有什么区别? - What is difference between System.Linq.Enumerable.WhereListIterator & System.Linq.Enumerable.WhereSelectListIterator? 对Xdocument的Linq查询返回“System.linq.Enumerable + WhereSelectEnumerableIterator&#39;2 [system.XML.Linq.Xelement,System.String] - Linq query on Xdocument returns "System.linq.Enumerable+WhereSelectEnumerableIterator'2[system.XML.Linq.Xelement,System.String] 意外错误:LINQ to Entities 无法识别方法“System.String DecryptValue(Byte[], System.String)”方法 - Unexpected Error : LINQ to Entities does not recognize the method 'System.String DecryptValue(Byte[], System.String)' method LINQ to Entities 无法识别“System.String Decrypt(System.String, System.String)”方法 - LINQ to Entities does not recognize the method 'System.String Decrypt(System.String, System.String)' method LINQ to Entities无法识别方法&#39;System.String getFullname(System.String,System.String)&#39; - LINQ to Entities does not recognize the method 'System.String getFullname(System.String, System.String)' 获取错误类型&#39;System.String&#39;不支持数组反序列化 - Getting error Type 'System.String' is not supported for deserialization of an array LINQ 到实体无法识别 System.String - LINQ to Entities Not recognize System.String 方法系统linq的类型参数可枚举为可枚举-错误 - the type arguments for method system linq enumerable as enumerable - Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM