Eric Funkhenbush’s answer is absolutely correct, considering it as a database problem. But I feel that you need a better structure for storing keyword data if you want to move it efficiently.
Please note that this answer is not intended to improve, it is intended to fix the problem in your data model, and not to adapt the environment to the existing (apparently erroneous, as there is a problem) data model that you have.
My main suggestion, regardless of the time limit (I understand that this is not the easiest fix), would be to add a separate table for keywords (with a many-to-many relationship with related classes).
[GROUPS] * ------- * [KEYWORD]
This will allow you to search for a keyword and only then get the elements associated with it, related to it (based on identifier, not complex string).
int? keywordID = DataContext.Keywords.Where(x => x.Name == keywordFilter).Select(x => x.Id).FirstOrDefault(); if(keywordID != null) { getGroup = DataContext.Groups.FirstOrDefault(group => group.Keywords.Any(kw => kw.Id == keywordID)); }
But I fully understand if this type of correction is no longer possible in the current project. I would like to mention this, though, if someone stumbles on this question in the future and still has the opportunity to improve the data structure.
Flater
source share