LINQ到具有多个Ilist的对象 [英] LINQ to objects with several Ilists
本文介绍了LINQ到具有多个Ilist的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在班级中创建了一些对象,但每个列表框中的项目都有一个IList.我试图弄清楚如何运行一个查询以合并所有查询并绑定到网格.每个列表都有一个唯一ID,然后可以将其用作查询的一部分.项目编号是我在每个列表框的搜索类中拥有的UID.这是我要构建的最后一个函数.
I have some objects created in my class but have more then one IList with my items from each list box. I am trying to figure out how to run one query to combine all of them and bind to a grid. Each list has a Unique ID which can then be used as part of the query. The project number is the UID which I have in my search class for each listbox. Here is the last function I am trying to build.
public void geteverythingforGRID()
{
List<SearchClass> siList = new List<SearchClass>();
List<SearchClass> siListREP = new List<SearchClass>();
DataTable dtSomeOtherDTQuery = BuildEverythingGRIDTable(
buildSaleRepQuery(), buildPMQuery());
DataRow[] drsO = dtSomeOtherDTQuery.Select("REP <> '" +
String.Empty + "' PM <> '" +
String.Empty + "'");
//This I can't figure out how to make it syntax correct
//but is what I need?
//DataRow[] drsO = dtSomeOtherDTQuery.Select("Sales_Rep <> '" +
// String.Empty + "'");
foreach (DataRow dr in drsO)
{
var s = from sr in siListREP
where sr.REP == dr["Sales_Rep"].ToString()
group sr by sr.REPEstimateNumber into g
join projmgr in siList on g.Key equals
siList.PMEstimateNumber
orderby projmgr.PM
select new { projmgr.PM, projmgr.REP };
foreach (var list in s)
{
gvSearch.DataSource = list;
gvSearch.DataBind();
}
}
}
推荐答案
这根本没有道理,甚至都不是有效的声明
This makes no sense at all and isn''t even a valid statement
dtSomeOtherDTQuery.Select("REP <> '" +
String.Empty + "' PM <> '" +
String.Empty + "'");
它翻译成
dtSomeOtherDTQuery.Select("REP <> '''' PM <> '''')
;
it translates to
dtSomeOtherDTQuery.Select("REP <> '''' PM <> '''')
;
这篇关于LINQ到具有多个Ilist的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文