From: Andrew Morton on
"Armin Zingler" wrote
>
> I'd like to order a query either by an Integer value or a String value.

Have you considered the LINQ Dynamic Query Library?

http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx

Andrew

From: Armin Zingler on
Mr. Arnold schrieb:
> You should pull the data 'q' with no order by
>
> This is C# example as close as I can get it. I don't have code in front
> of me.
>
> var a = q.orderacending(b => b.Property).Tolist();
>
>
> I don't know if you have Lambda statement in VB.

I'm afraid, I can't read and translate this sCrabble# code. Thx anyway.


--
Armin
From: Armin Zingler on
Cor Ligthert[MVP] schrieb:
>> I don't know if you have Lambda statement in VB.
>
> 2010

It is 2010. ;)

--
Armin

From: Armin Zingler on
Armin Zingler schrieb:
> 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 got a reply (in the German group) that solves the problem. It says:

dim q = from bla in blub

select case condition
case 1
q = from bla in q order by bla.IntegerProperty
case 2
q = from bla in q order by bla.StringProperty
end select

'access q here

The trick is to assign the second query to the same variable as the first
one. Before, I wanted to assign it to another variable (q2) which created
the question of how to declare it.

Thx anyway for reading and replying.


--
Armin

From: Armin Zingler on
Andrew Morton schrieb:

> Have you considered the LINQ Dynamic Query Library?

Not yet, but I'll have a look. Thanks.

> http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx


--
Armin

First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: database application
Next: Question on MDIchild forms