Bonjour,
je suis sur une page de recherche d'un objet dans laquelle il est possible de remplir une textbox avec des mots clés séparés par des espaces.
J'attaque ma base de données via EntityFramework en créant des requêtes linq.
Mon objet recherché à un identifiant fonctionnel (CartoEntry) et un code (CartoEntry_CodBasicat).
Si ma zone de mots clés contient 2 mots (A et B), je dois avoir un where qui ressemble à ça :
Actuellement j'ai ma requête qui fait un select puis je lui applique les filtres :
Code : Sélectionner tout - Visualiser dans une fenêtre à part (CartoEntry like '%A%' and CartoEntry like '%B%') or (CartoEntry_CodBasicat like '%A%' and CartoEntry_CodBasicat like '%B%')
Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 var requete = from obj in bdd.T_CartoEntry_Description orderby obj.CartoEntry select new CartoEntryDto { CartoEntryId = obj.CartoEntry, CartoEntryBasicat = obj.CartoEntry_CodBasicat, CartoEntryStatus = obj.CartoEntry_Status, CartoEntryObjectType = obj.CartoEntry_Object_Type, CartoEntryOrigin = obj.CartoEntry_Origin }; // GERER les restrictions if (!String.IsNullOrEmpty(dto.Letter)) { requete = requete.Where(p => p.CartoEntryId.StartsWith(dto.Letter)); } if (!String.IsNullOrEmpty(dto.Keyword)) { // ICI est mon problème } // EXECUTER la requête list = requete.ToList();
Auriez-vous une piste ?
Partager