how to specify literal value in linq union
Posted
by lowlyintern
on Stack Overflow
See other posts from Stack Overflow
or by lowlyintern
Published on 2010-05-20T11:18:17Z
Indexed on
2010/05/20
11:20 UTC
Read the original article
Hit count: 208
I have the following SQL query, note I want the literal value '0' in the second field in the second SELECT statement from the ItemSale table. How do I express this in LINQ? I get the error message 'Invalid anonymous type member declarator'.
SELECT BranchNumber,QuantitySold FROM Department UNION SELECT BranchNumber,0 FROM ItemSale
How to express the '0' in LINQ?
var unionQuery = (from dept in Department select new { dept.BranchNumber, dept.QuantitySold, }) .Concat(from item in ItemSale select new { item.BranchNumber, 0 });
© Stack Overflow or respective owner