Hi,
I have two LINQ queries that produce two different results, but the fields, while having different names, are essentially the same. I am trying to union them together (although concat in this case should produce the same results), but I am getting an error. My thought is that I somehow need to declare the type of the resulting fields, but I am not sure how to do that and if it is correct. Could anyone guide me down the right path to figure out what is wrong? Thanks very much. I have the code and the error below.
var gen= from g in db.tbl_Generator
join a in db.tbl_Gen_Allocation on g.Unit_ID equals a.Unit_ID
join t in strContractType on 1 equals 1
where a.Begin_Date <= dteEnd && a.End_Date >= dteBegin
select new { g.Generator_Name, g.ISO_Asset_ID, a.Begin_Date, a.End_Date, a.System_ID };
//Get all gen in this time frame
var con = from c in db.tbl_Contracts
join a in db.tbl_Contracts_Allocation on c.Contract_ID equals a.Contract_ID
join t in strContractType on 1 equals 1
where a.Begin_Date <= dteEnd && a.End_Date >= dteBegin
select new { c.Name, c.Contract_ID, a.Begin_Date, a.End_Date, a.System_ID };
//union gens and contracts
var unionResources = gen.Union(con);
Error 1 'System.Linq.IQueryable<AnonymousType#1>' does not contain a definition for 'Union' and the best extension method overload 'System.Linq.ParallelEnumerable.Union<TSource>(System.Linq.ParallelQuery<TSource>, System.Collections.Generic.IEnumerable<TSource>)' has some invalid arguments