how di O formulate the foolowing in LINQ with LAMBDA expressions.

Given (for simplicity - this is actually later a join) a table with the fields:

  • Item
  • Price
  • Timestamp

which is mapped to a class. I use BlToolkit, but could also be LINQ or ETF - makes no differnce.

I want the object with Item = 2 and the hightst timestamp (newest) and / or a query of ALL items but ONLY the most current object.

How do I formulate this?

I understand this likely will be a subselect ivolved, but I have a problem finding the correct syntax.

link|flag

68% accept rate

1 Answer

Using fluent syntax, the item with the highest timestamp, and Item==2 is:

var item= table.Where(i => i.Item == 2)
               .OrderBy(i => i.Timestamp)
               .SingleOrDefault();
link|flag

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.