views:

92

answers:

1

Hi there, I've got a problem with a search mechanic like as we sometime see on site. I've a big list of says, person. The way to filter a a list of : "#, A, B, C, D, E, [...]".

The problèm I have its when i execute de query with EF, an error pop out. Here's is my code.

Code :

var query = from  p in m_context.Persons
            where char.IsDigit(p.Name, 0)
            select a;

The error says that it's impossible to convert it into a valid expression against the database. So, is there anyway to do it?

Thanks guy.

UPDATE =======================

Here's my error.

LINQ to Entities does not recognize the method 'Boolean ContainsChar' method, and this method cannot be translated into a store expression.

+3  A: 

Hello, I think I found the solution:

var query = m_context.Persons.Where("substring(it.Name, 1, 1) in MULTISET('0','1','2','3','4','5','6','7','8','9')");

references:

Entity SQL Quick Reference

bniwredyc
It's working! Thank a lot!
Simon