kmitch62
asked on
Use Linq to entities to filter on alpha and numeric values
I have the following code in my method
MyListViewModel viewModel = new MyListViewModel {
MyList= repository.MyList
.Where(m=> alphaFilter == (string)null || m.Title.StartsWith(alphaFi lter))
this filters the list based on the first character in the string. It works perfectly if the value passed as alphaFilter matches the first character of a the m.title.
My problem is that i want an alpha character to filter on the same character, but i want to be able to pass a "#" character and retrieve all entries that start with a numeric value.
in other words, i want my select list of alphaFilter characters to look like this...
# A B C D
not
1 2 3 4 5 6 7 8 9 0 A B C D
I know there is probably an easy solution, but i'm having trouble finding it. Any help would be much appreciated
MyListViewModel viewModel = new MyListViewModel {
MyList= repository.MyList
.Where(m=> alphaFilter == (string)null || m.Title.StartsWith(alphaFi
this filters the list based on the first character in the string. It works perfectly if the value passed as alphaFilter matches the first character of a the m.title.
My problem is that i want an alpha character to filter on the same character, but i want to be able to pass a "#" character and retrieve all entries that start with a numeric value.
in other words, i want my select list of alphaFilter characters to look like this...
# A B C D
not
1 2 3 4 5 6 7 8 9 0 A B C D
I know there is probably an easy solution, but i'm having trouble finding it. Any help would be much appreciated
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
as for the answer... that's exactly what i needed and I don't believe that i didn't see it myself. Like i said, a simple answer that i was just missing. Thanks for the help.