hi all
I want to combine 2 queries in in one. I have following code and how will i write LINQ to combine it -
var List = (from m in resellers
select new SelectListItem
{
Text = m.Rr,
Value = m.RrId.ToString(),
Selected = m.rId == cId
}).OrderBy(t => t.Text).ToList();
ViewBag.rrs = List;
How will I send or add above LINQ's output to my 2nd LINQ which is given below -
reportsViewModel.MList = (from m in array //join p in rrs on m equals p.RrId
select new MModel
{
mth = m.Key,
views = m.Value
}).OrderBy(t => rrs).ToList();
I tried to join it but it is giving me an error....
Thanks in advance.... any help is appreciated...
VulpesPosted Dec 19, 2013, 11:19 AM
So as long as the types of 'm' and the property, p.RrId, are the same, then the join should work
However, I've just noticed that 'p' doesn't have a property called RrId. The ones it does have are called Text, Value and Selected which appear to be of types string, string and bool respectively.
swami swamiPosted Dec 19, 2013, 11:09 AM
VulpesPosted Dec 19, 2013, 11:04 AM
However, the OrderBy clause looks wrong as your only choices are t.mth or t.views.
swami swamiPosted Dec 19, 2013, 10:39 AM
Jignesh TrivediPosted Dec 19, 2013, 12:23 AM
if you want to add one collection to other collection then both collection must have same type.
so first of all make these two collection have same type and then you can use union to combine this collections.
hope this will help you.
Jaganathan BantheswaranPosted Dec 19, 2013, 12:05 AM