Question : Linq to Sql union with constant values

Hi ,
how to union the return value with constant ?

my code comes the error says the union type incompitable.

I have to union them on linq becase this is used for a lookup control.
Code Snippet:
1:
2:
3:
4:
5:
var staffs=from rs in DBLinq.tblFacilityStaffs                                 
                                  select new { OptName = string.Format("{0} {1}", rs.FirstName, rs.LastName), rs.UNID };
var extrastaff=(from rs in DBLinq.tblFacilityStaffs
                            select new { OptName = "", UNID = 0 }).Take(1);
            bsstaff.DataSource = staffs.Union(extrastaff);

Answer : Linq to Sql union with constant values

I believe what you need to use is the AsEnumerable method, as in this example:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
            AdventureWorksData dc = new AdventureWorksData();
 
            var q1 = from employee in dc.vEmployees
                    select new { First = employee.FirstName, Last = employee.LastName };
 
            var q2 = from employee in dc.vEmployees
                     select new { First = "(Blank)", Last = "(Blank)"};
 
            var result = q2.AsEnumerable().Union(q1);
 
            foreach (var r in result)
            {
                Console.WriteLine(r.First + " " + r.Last);
            }
Random Solutions  
 
programming4us programming4us