public IList <IWhatIs> GetMatchingWhatIsSubjects(string obj, string relation, string answer) { return(WhatIs.Where( whatIs => whatIs.Answer.Equals(answer, StringComparison.InvariantCultureIgnoreCase) && whatIs.Object.Equals(obj, StringComparison.InvariantCultureIgnoreCase) && whatIs.Relation.Equals(relation, StringComparison.InvariantCultureIgnoreCase)) .ToList <IWhatIs>()); }
public IList <IWhatIs> GetMatchingWhatIsAnswers(string subject, string obj, string relation) { var allWhatIs = WhatIs.ToList <IWhatIs>(); var singularResults = WhatIs.Where( whatIs => whatIs.Subject.ToLowerInvariant().Equals(subject.ToLowerInvariant()) && whatIs.Object.ToLowerInvariant().Equals(obj.ToLowerInvariant()) && whatIs.Relation.ToLowerInvariant().Equals(relation.ToLowerInvariant())) .ToList <IWhatIs>(); if (singularResults.Count == 1) { return(singularResults); } return(WhatIs.Where( whatIs => whatIs.Subject.ToLowerInvariant().Contains(subject.ToLowerInvariant()) && whatIs.Object.ToLowerInvariant().Equals(obj.ToLowerInvariant()) && whatIs.Relation.ToLowerInvariant().Equals(relation.ToLowerInvariant())) .ToList <IWhatIs>()); }