Here is my problem. We've got a list of enterprises, users or anything and we must search into it with a "StartsWith" search type. So on our site, we ain't got a Search field such as a Textbox but we've got a search header including 27 buttons "#", "A", "B", "C", [...] "Z".
The problem we have is that if user click on "E" button, when we querying to get value from database, entreprises name may start with an "É", "È", "Ê", bacause yes, our site is in french. Any idea of how to do it in LINQ.
This is important to know too that we're using LLBLGen Pro. So I guess it need to have something he can convert into a valid SQL Query.
Here is what we've already tryied :
IList<Enterprise> enterprises; switch (searchChar){ [...] case "E": enterprises = from ent in ourContext.Enterprises where "eèéêë".Any(param => ent.name[0] == param) select ent; break; [...] }
Which give us this error something relatively to a unconvertable query:
Unable to cast object of type 'System.Linq.Expressions.ConstantExpression' to type 'SD.LLBLGen.Pro.LinqSupportClasses.ExpressionClasses.SetExpression'.
So we've tried to make it basicaly with a simple LINQ query, without querying to DB to know if it's possible.
IList<string> test = new List<string>() { "École", "enlever", "avoir" }; IList<string> result = (from value in test where "eéèêë".Contains(value[0].ToString()) select value).ToList();
What is weird with this query, is that it ain't crash. But, it ain't work too! When debugging, it go throught it, but when we try to see what is into "result" list, it's like if there's nothing in it. I mean, the list is simply null. But nothing fail into the try catch!
Please help !