2011-12-28 65 views
2

我有Linq到SQL查詢返回一個字段與Url,我將它綁定到asp.net組合框。我需要在綁定結果之前將新的虛擬記錄(「All Url」)添加到Linq to SQL結果中。怎麼做?Linq添加額外的數據到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

項目添加到組合框,然後附加數據綁定物品:

ddlDomain.Items.Add(new ListItem() { Text = "All Url" }); 
ddlDomain.AppendDataBoundItems = true; 
ddlDomain.DataSource = results; 
ddlDomain.DataBind(); 
相關問題