LINQ and EF with string .StartWith (char c)

I have a problem with the search engine we once see on the site. I have a long list of people. List filtering method: "#, A, B, C, D, E, [...]".

The problem I have is when I execute a query with EF an error is thrown. Here 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 is not possible to convert it to a valid expression in the database. So, do it anyway?

Thanks guy.

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

Here is my mistake.

LINQ to Entities does not recognize the method "Boolean Contains [Char] (System.Collections.Generic.IEnumerable1) [System.Char], Char)", and this method cannot be translated to store expression.

+2


source to share


1 answer


I think I found a solution:

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

      



links:

Entity SQL Quick Reference

+3


source







All Articles