A
Armin Zingler
Hi,
I'd like to order a query either by an Integer value or a String value.
I could write
select case condition
case 1
dim q = from bla in blub order by bla.IntegerProperty
case 2
dim q = from bla in blub order by bla.StringProperty
end select
This is of no use because I have to access q after "end select". But
if I declared it before "select case", I'd have to write
dim q as IOrderedEnumerable(Of TElement)
However, "TElement" is an anonymous type, so I can't do this also.
Is it possible to use a Comparer with the Order By clause anyhow?
Or, instead, can I achieve my goal by directly calling the extension method
System.Linq.Enumerable.OrderBy(Of TSource, TKey) anyhow?
In whichever direction I think, I always need the anonymous type. Probably
I do not and it's very simple, actually. Anybody's got a suggestion?
I'd like to order a query either by an Integer value or a String value.
I could write
select case condition
case 1
dim q = from bla in blub order by bla.IntegerProperty
case 2
dim q = from bla in blub order by bla.StringProperty
end select
This is of no use because I have to access q after "end select". But
if I declared it before "select case", I'd have to write
dim q as IOrderedEnumerable(Of TElement)
However, "TElement" is an anonymous type, so I can't do this also.
Is it possible to use a Comparer with the Order By clause anyhow?
Or, instead, can I achieve my goal by directly calling the extension method
System.Linq.Enumerable.OrderBy(Of TSource, TKey) anyhow?
In whichever direction I think, I always need the anonymous type. Probably
I do not and it's very simple, actually. Anybody's got a suggestion?