thegunner
thegunner

Reputation: 7153

where clause in linq list

H, I have a list of orders and I'm trying to filter this list. So far I have:

    Dim orders = _orderController.LoadAll().ToList()

which does indeed give me a list of orders which I can display on a gridview.

How could I filter this list to say: where order.referencenumber = "abc123"

and only give me one order in the list to display in the gridview

Cheers,

Upvotes: 0

Views: 933

Answers (2)

Jens Kloster
Jens Kloster

Reputation: 11277

You should apply the Where clause before your call to ToList

 Dim orders = _orderController.LoadAll().Where(Function(c) c.referencenumber = "abc").ToList()

you should check you the examples found in the documentaion

Upvotes: 0

Bas Slagter
Bas Slagter

Reputation: 9929

Try this:

VB:

Dim orders = _orderController.LoadAll().Where(Function(c) c.referencenumber = "abc").ToList();

C#:

var orders = _orderController.All().Where(o => o.referencenumber = "abc123").ToList();

Upvotes: 1

Related Questions