Long story short I need to get items based on a range (high/low value), however the column/property from the database is a string
and I'm not allowed to change that. So how am I supposed to compare a range?
I can't seem to find a way to convert the entity property to an int
so i can compare.
Of course Convert.toInt32
doesn't work either. I don't see any SqlFunctions
that will help but maybe I'm overlooking something easy.
I've been playing with it, but so far no luck. This is my latest try that doesn't work:
var result = Repo.Query().Where(e => e.SerialNumber.Cast<int>().First() >= myIntLowVariable && e.SerialNumber.Cast<int>().First() <= myIntHighVariable);
Any suggestions?
Update
The user enters two SerialNumbers and I need to return all the records in that range, however SerialNumber
is a string/varchar
column/property.
Data - Sorry no idea how to put a table in here..
SN :: Description
1 :: Milk
2 ::Eggs
3 :: Bread
4 :: Cheese
5 :: Bacon
6 :: Yogurt
7 :: Mustard
8 :: Chicken
9 :: Pizza
10 :: Chips