问题描述
代码是这样的List<RailwayProject.Entities.DataAnalyze>list=fromaindb.TestDatajoinbindb.TestObjectona.object_idequalsb.object_idjoinOrganization1indb.Organizationona.org_idequalsOrganization1.OrgIdjoinOrganization2indb.OrganizationonOrganization1.ParentIdequalsOrganization2.org_idjoinOrganization3indb.OrganizationonOrganization2.ParentIdequalsOrganization3.org_idjoinOrganization4indb.OrganizationonOrganization3.ParentIdequalsOrganization4.org_idjoinindexResultindb.IndexResultona.data_idequalsindexResult.data_idselectnewRailwayProject.Entities.DataAnalyze{a.data_id};然后提示错误1无法使用集合初始值初始化类型“RailwayProject.Entities.DataAnalyze”,原因是它未实现“System.Collections.IEnumerable”这样的错误,不知道怎么转...
解决方案
解决方案二:
ToList()一下。
解决方案三:
List<RailwayProject.Entities.DataAnalyze>list=fromaindb.TestData前面这段改成varlist=fromaindb.TestData后面改成selectnew{a.data_id};然后用list.tolist()一下
解决方案四:
2楼正解,ToList后才会查询。
解决方案五:
publicclassDataAnalyze{publicintOrgId{get;set;}//取出你的想要的字段或者怎么处理}List<RailwayProject.Entities.DataAnalyze>list=(fromaindb.TestDataselectnewRailwayProject.Entities.DataAnalyze{OrgId=a.org_id,ParentId=a.ParentId//依次往下写。}).ToList<RailwayProject.Entities.DataAnalyze>();