Simple linq question

T

Tony Johansson

Hello!

I have a collection called WorksheetRowParameterList consisting of the
following object
string ID;
string OriginalParameterID;
string Parameter;
string Duplicate;
string Value;
string WorksheetRowID;

I want to get all object from this collection that have
parameter that exist in an array callad paramArray.
The type of the item in the paramArray is string.

I want also to order on WorksheetRowID ascending

I have written the following linq query
var answer = from o in WorksheetRowParameterList
where paramArray.Contains(o.Parameter)
orderby o.WorksheetRowID ascending
select o;

I get all the objects but not in the correct order because I want
object with the lowest WorksheetRowID first and the last object should have
the highest WorksheetRowID

According to the documentation this should be correct.

//Tony
 
M

Martin Honnen

Tony said:
I have a collection called WorksheetRowParameterList consisting of the
following object
string ID;
string OriginalParameterID;
string Parameter;
string Duplicate;
string Value;
string WorksheetRowID;

I want to get all object from this collection that have
parameter that exist in an array callad paramArray.
The type of the item in the paramArray is string.

I want also to order on WorksheetRowID ascending

I have written the following linq query
var answer = from o in WorksheetRowParameterList
where paramArray.Contains(o.Parameter)
orderby o.WorksheetRowID ascending
select o;

I get all the objects but not in the correct order because I want
object with the lowest WorksheetRowID first and the last object should
have the highest WorksheetRowID

How do these WorksheetRowID values look exactly? Currently you have type
string and then get them ordered as strings. Perhaps you want to treat
them as numbers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top