Reputation: 41
I have a a line of code that looks like this
var results = DataBase.Find(x.ImportanceFactor > 5 && x.ImportanceFactor < 10);
Now in the Find
function, what Data Structure can i use?
public static int Find(??? input)
{
:
Some Code
:
}
The format needs to be exactly how i specified above, but i have having a hard time finding a data structure to support it. I have tried a number of Expressions in Linq
to no success.
EDIT For Clarification:
The Find
function will go into the a database and look for an object whose importance is within the specified range, and return whichever object in that range has the highest Size value. Again, that first line cant be changed in any way, regardless of what happens in the Find function. The line below needs to be available in the Find
x.ImportanceFactor > 5 && x.ImportanceFactor < 10
EDIT2:
X is a dynamic expression, not an object with properties.
Upvotes: 0
Views: 51
Reputation: 219047
This:
x.ImportanceFactor > 5 && x.ImportanceFactor < 10
is just a bool
:
public static int Find(bool input)
But given the usage of x
in that condition, I suspect you actually meant this:
var results = DataBase.Find(x => x.ImportanceFactor > 5 && x.ImportanceFactor < 10);
In which case you're looking at something structurally very similar to methods like Any()
or Where()
on IEnumerable<T>
. That would use something more like Func<T, bool>
:
public static int Find<T>(Func<T, bool> input)
Upvotes: 1