Simple linq question

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
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
 
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.
 
Back
Top