linq merge elements with orderby
- by Sanja Melnichuk
Hi all. I need to select all terminals sorted by Attributes[2]
// get all query
IQueryable<ITerminal> itt = repository.Terminals.GetQuery();
// get all with Attributes[2]
IQueryable<ITerminal> itt2 = itt
.Select(item => new
{
attrs = item.Attributes[2],
term = item
})
.OrderBy(x => x.attrs)
.Select(x => x.term);
Now how to select from itt all terminals but ordered by itt2 results? How to order them by itt2?
Example:
itt = c,d,r,a,w,b
itt2 = a,b,c // after select
and after merge: a,b,c d,r,w
Thanks all