linq 결과에 항목을 추가하고 싶습니다. 여기에 내 초기 쿼리가 있습니다.LINQ 쿼리에 다른 단일 익명 형식을 추가하는 방법은 무엇입니까?
gvGroups.DataSource = groups.ToList();
을하지만 사전에 내가 여기에 또 하나 개의 행을 추가 할 :
var groups = from gr in monitors.groupiddeviceids
where gr.device.customerID == customerID
group gr by gr.grouping.GroupName into g
select new { Group = g.Key, Devices = g.Count() };
나는 이런있는 gridview 데이터 소스에 이것을 넣고 싶다. 행은 {string, int} 형식입니다. 추가하려는 행에 { "할당되지 않음", 14}이 (가) 있어야합니다.
linq 목록에 항목을 추가하려면 어떻게해야합니까?
groups.ToList(). Add (new {Group = "UnAssigned", Devices = 14}); gvGroups.DataSource = 그룹; ? – brz
http://stackoverflow.com/questions/5240412/add-an-anonymous-object-to-an-anonymous-list – Minja