如何将连接查询添加到列表 [英] how to add the join query to list
本文介绍了如何将连接查询添加到列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
List<CompanyInfo> lstinfo = new List<CompanyInfo>();
CompanyInfo ci=new CompanyInfo();
var query = from o in xfeed.ciqCompanies
join c in xfeed.ciqBusinessDescriptions on o.companyId equals c.companyId
select new
{
o.companyId,
o.companyName,
o.officeFaxValue,
o.officePhoneValue,
o.streetAddress,
o.city,
c.businessDescription
};
List<CompanyInfo> adf= query.ToList();//this line is error
如何将加入的查询添加到列表
how to add the joined query to list
推荐答案
尝试像下面:
Try like below:
List<CompanyInfo> adf = (from o in xfeed.ciqCompanies
join c in xfeed.ciqBusinessDescriptions on o.companyId equals c.companyId
select new CompanyInfo
{
companyId = o.companyId,
companyName = o.companyName,
officeFaxValue = o.officeFaxValue,
officePhoneValue = o.officePhoneValue,
streetAddress = o.streetAddress,
city = o.city,
businessDescription = c.businessDescription
}).ToList();
确保在CompanyInfo类中定义companyI,companyId,officeFaxValue,..属性。如果不同,则可以根据需要进行更改。
Make sure that companyI, companyId, officeFaxValue,.. properties are defined in CompanyInfo class. If it is different then you can change as per your need.
这篇关于如何将连接查询添加到列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文