I know there are a lot of examples of this on the web, but I can't seem to get this to work.
Let me try to set this up, I have a list of custom objects that I need to have limited on a range of values.
I have a sort variable that changes based on some action on the UI, and I need to process the object differently based on that.
Here is my object:
MyObject.ID
- Just an identifier
MyObject.Cost
- The cost of the object.
MyObject.Name
- The name of the object.
Now I need to filter this based on a range in the cost, so I will have something similar to this, considering that I could be limiting by Either of my bottom two properties.
var product = from mo in myobject
where mo.Cost <= 10000
OR
var product = from mo in myobject where mo.Name equals strName
Now I have the dynamic linq in my project, but I'm not figuring out how to get it to actually work, as when I do some of the examples I am only getting:
Func<Tsourse>bool>predicate
as an option.
Edit I am trying to find a solution that helps me Objectify my code, as right now it is a lot of copy and paste for my linq queries.
Edit @Stan
Is there an obvious performance difference between:
var product = from mo in myobject
... a few joins ...
where mo.Cost <= 10000
And
var product = (from mo in myobject
... a few joins ...)
.AsQueryable()
.Where("Cost > 1000")