代码是这样的ListRailwayProject.Entities.DataAnalyzelistfromaindb.TestData 代码是这样的Listlist=fromaindb.TestData joinbindb.TestObjectona.object_idequalsb.object_id joinOrganization1indb.Organizationona.org_idequalsOrganization1.
代码是这样的ListRailwayProject.Entities.DataAnalyzelistfromaindb.TestData 代码是这样的Listlist=fromaindb.TestData joinbindb.TestObjectona.object_idequalsb.object_id joinOrganization1indb.Organizationona.org_idequalsOrganization1.OrgId joinOrganization2indb.OrganizationonOrganization1.ParentIdequalsOrganization2.org_id joinOrganization3indb.OrganizationonOrganization2.ParentIdequalsOrganization3.org_id joinOrganization4indb.OrganizationonOrganization3.ParentIdequalsOrganization4.org_id joinindexResultindb.IndexResultona.data_idequalsindexResult.data_id selectnewRailwayProject.Entities.DataAnalyze { a.data_id }; 然后提示错误 1 无法使用集合初始值初始化类型“RailwayProject.Entities.DataAnalyze”,原因是它未实现“System.Collections.IEnumerable” 这样的错误,不知道怎么转...
4 个解决方案
#1
ToList()一下。
#2
Listlist=fromaindb.TestData 前面这段改成 varlist=fromaindb.TestData 后面改成 selectnew { a.data_id }; 然后用list.tolist()一下
#3
2楼正解,ToList后才会查询。
#4
publicclassDataAnalyze{publicintOrgId{get;set;}//取出你的想要的字段或者怎么处理}Listlist=(fromaindb.TestDataselectnewRailwayProject.Entities.DataAnalyze{OrgId=a.org_id,ParentId=a.ParentId//依次往下写。}).ToList();