コード例 #1
0
        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>());
        }