【发布时间】:2010-08-20 15:06:23
【问题描述】:
我正在使用Linq 查询来填充GridView。
然后我将其设置为Datasource。
在排序事件中,我想检索查询生成的匿名类型并找到成员名称。
可以这样做吗?
这是一个查询示例
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;
我可以在排序事件中做些什么来检索匿名类型并做类似的事情
employeeList.Sort((x, y) => ((Int32)x.GetType().GetProperty(e.SortExpression).GetValue(x, null)).CompareTo((Int32)y.GetType().GetProperty(e.SortExpression).GetValue(y, null)) * sortValue);
【问题讨论】:
-
需要什么会员名?你能举个例子,一些代码吗?谢谢!