我有Linq to SQL查询,它使用Url返回一个字段,然后将其绑定到asp.net组合框。我需要在绑定结果之前将新的虚拟记录(“All Url”)添加到Linq to SQL结果中。怎么做?
var results =
dataAccess.Statistics.
Where(s => s.DateStamp >= minDate && s.DateStamp <= DateTime.UtcNow && s.UserId == userId).
GroupBy(s => s.Url).
Where(g => g.Count() > 1).
OrderBy(g => g.Count()).
Select(g => new { Url = dataAccess.getDomain(g.Key) });
ddlDomain.DataSource = results;
ddlDomain.DataBind();
答案 0 :(得分:0)
将项添加到组合框,然后附加数据绑定项:
ddlDomain.Items.Add(new ListItem() { Text = "All Url" });
ddlDomain.AppendDataBoundItems = true;
ddlDomain.DataSource = results;
ddlDomain.DataBind();