i trying use union follows :
var query1 = c in dc.hotel_meals_tbls c.chdlunch != "0" && c.chdlunch != "" select new { service_code = c.hotelcodeid, service_name = c.hotelname, room_category = "", room_type = "", variance_name = "childlunch", market = "ww", contract_business_year = "2014/2015", contract_start_date = "01/11/2014", contract_end_date = "30/10/2015", type = "child policy", currency = c.currencycode, period_name = "", period_start_date = "", period_end_date = "", price = c.lunch, percentage = c.chdlunch + "%", num_to_stay = "", num_to_pay = "", penalty_time_limit = "", penalty_no_day_before = "", child_reference = "", text = c.childpolicy }; var query2 = c in dc.hotel_meals_tbls d in dc.hotelperiod_tbls f in dc.hotelroom_tbls c.hotelcodeid == d.hotelcodeid && c.hotelcodeid == f.hotelcodeid && f.dbl_highseason != 0 && d.periodname == "high" select new { service_code = c.hotelcodeid, service_name = c.hotelname, room_category = f.roomname, room_type = "dbl", variance_name = "", market = "ww", contract_business_year = "2014/2015", contract_start_date = "01/11/2014", contract_end_date = "30/10/2015", type = "cost", currency = c.currencycode, period_name = d.periodname, period_start_date = d._from, period_end_date = d._to, price = f.sgl_lowseason, percentage = "", num_to_stay = "", num_to_pay = "", penalty_time_limit = "", penalty_no_day_before = "", child_reference = "", text = "" }; var result = query1.union(query2);
and got errors:
'system.linq.iqueryable<anonymoustype#1>'
not contain definition 'union' , best extension method overload'system.linq.parallelenumerable.union<tsource>(system.linq.parallelquery<tsource>, system.collections.generic.ienumerable<tsource>)'
has invalid argumentsinstance argument: cannot convert
'system.linq.iqueryable<anonymoustype#1>'
'system.linq.parallelquery<anonymoustype#2>'
truly used method many times without errors...do have idea wrong in query?
the error message indicates .net thinks 2 anonymous types different. in order 2 anonymous types same must have same number of properties same names , types. i've gone through property list , appear have same names in same order. however, it's possible you've got different types in these areas:
type 1
period_start_date = "" period_end_date = "" price = c.lunch, text = c.childpolicy
type 2
period_start_date = d._from period_end_date = d._to price = f.sgl_lowseason text = ""
make sure d._from
, d._to
, , c.childpolicy
strings , c.lunch
, f.sgl_lowseason
same type (e.g. maybe 1 int
, other decimal
).
Comments
Post a Comment