我正在使用Linq
查詢來填充GridView
。然後我將它設置爲Datasource
。GridView和Linq查詢排序
在排序事件中,我想要檢索查詢生成的匿名類型並查找成員名稱。
是否可以這樣做?
下面是查詢的爲例
var q = from inboundCall in dc.GetTable<InboundCall>()
join employee in dc.GetTable<Employee>() on inboundCall.EmployeeID equals employee.ID
join code in dc.GetTable<Code>() on inboundCall.CodeID equals code.ID
join site in dc.GetTable<Site>() on inboundCall.SiteID equals site.ID
where inboundCall.IsSuccess == true
select new
{
EmployeeNumber = employee.Number,
EmployeeName = employee.Name,
CallerID = inboundCall.CallerID,
SiteName = site.Name,
CallDate = inboundCall.CallDate,
CodeName = code.Name
};
然後
gridData.DataSource = q;
我可以在排序事件retieve匿名類型,做這樣的事情
employeeList.Sort((x, y) => ((Int32)x.GetType().GetProperty(e.SortExpression).GetValue(x, null)).CompareTo((Int32)y.GetType().GetProperty(e.SortExpression).GetValue(y, null)) * sortValue);
做
你需要什麼成員名?你能舉一個例子,一些代碼嗎?謝謝! – 2010-08-20 15:25:44