This question is locked. New answers and comments are not allowed.
I'm new both MVC/Telerik as well as the Entity Framework, having been an ASP.Net WebForms programmer for a long time, and I'm on a new project (for me), and am having a dickens of a time figuring out this issue.
While the project is new to me, it has a lot of existing code that would be difficult to change. I'm looking for the best, reasonably quick solution.
We have a form that allows a search for people in the database by their first and names and date of birth, and a list is returned using standard HTML controls. The date field is fine, but the first and last names have multiple kinds of searches... all of which but one correspond with the values in the Telerik FilterOperator... LIKE. They want to be able to enter an expression like this:
'J*N*S'
...and have it match JONES, JANUS, JINKS, JINOPS, etc. In this PARTICULAR case I can add three expressions 'StartsWith', 'EndsWith' and 'Contains' and that would work. I get into problems when they do a query that is like 'A*B*C*D' where B must appear before C in the name and B/C have characters between them.
They do this because they are sometimes reading from a piece of paper where they can make out say the 2nd, 3rd, 6th and 8th letter but not the others.
Writing a SQL LIKE statement is easy for me, but there is an abstraction being done of using Entity Framework against views in the system and those views are called through reflection. So I'm having to deal with code like this:
What I'd really like is to see a FilterOperator.Like implemented ;) But that's asking for a lot. Does anyone know how I can write a where clause using one of the existing FilterOpeartor enumerations that would successfully generate a LIKE 'A%B%C%D' on the SQL server side for an input of "A*B*C*D" entered into the form?
ASP.Net MVC 3
Windows Server 2008
Browsers targeting IE7 and better
Library is Telerik.Web.MVC 2011.2.712.340
While the project is new to me, it has a lot of existing code that would be difficult to change. I'm looking for the best, reasonably quick solution.
We have a form that allows a search for people in the database by their first and names and date of birth, and a list is returned using standard HTML controls. The date field is fine, but the first and last names have multiple kinds of searches... all of which but one correspond with the values in the Telerik FilterOperator... LIKE. They want to be able to enter an expression like this:
'J*N*S'
...and have it match JONES, JANUS, JINKS, JINOPS, etc. In this PARTICULAR case I can add three expressions 'StartsWith', 'EndsWith' and 'Contains' and that would work. I get into problems when they do a query that is like 'A*B*C*D' where B must appear before C in the name and B/C have characters between them.
They do this because they are sometimes reading from a piece of paper where they can make out say the 2nd, 3rd, 6th and 8th letter but not the others.
Writing a SQL LIKE statement is easy for me, but there is an abstraction being done of using Entity Framework against views in the system and those views are called through reflection. So I'm having to deal with code like this:
FilterOperator filterOperator = (FilterOperator)System.Enum.Parse(typeof(FilterOperator), dateFilter); filterDescriptors.Add(new FilterDescriptor("Person.LastName", filterOperator, lastName));var tickets = Repository.Tickets.All .Include(p2 => p2.ResponsibilityAreas.Select(j => j.MyArea)) .Sort(sortDescriptors) .Where(filterDescriptors);What I'd really like is to see a FilterOperator.Like implemented ;) But that's asking for a lot. Does anyone know how I can write a where clause using one of the existing FilterOpeartor enumerations that would successfully generate a LIKE 'A%B%C%D' on the SQL server side for an input of "A*B*C*D" entered into the form?
ASP.Net MVC 3
Windows Server 2008
Browsers targeting IE7 and better
Library is Telerik.Web.MVC 2011.2.712.340