Build() static private method

Builds a TermCriteria or TermsCriteria, depending on how many values are present in the values collection.
static private Build ( TermsExecutionMode executionMode, string field, MemberInfo member ) : ITermsCriteria
executionMode TermsExecutionMode The terms execution mode (optional). Only used when a is returned.
field string The field that's being searched.
member System.Reflection.MemberInfo The member information for the field.
return ITermsCriteria
コード例 #1
0
ファイル: OrCriteria.cs プロジェクト: wikes82/ElasticLINQ
        /// <summary>
        /// Takes a collection of <see cref="ICriteria" /> and if they are all
        /// <see cref="ITermsCriteria" /> for the same field replaces them with a single
        /// <see cref="ITermsCriteria" /> containing all terms for that field.
        /// </summary>
        /// <param name="criteria">collection of <see cref="ICriteria" /> that might be combined.</param>
        /// <returns><see cref="ITermsCriteria" /> containing all terms for that field or null if they can not be combined.</returns>
        static ICriteria CombineTermsForSameField(ICollection <ICriteria> criteria)
        {
            var termCriteria   = criteria.OfType <ITermsCriteria>().ToArray();
            var areAllSameTerm = termCriteria.Length == criteria.Count &&
                                 termCriteria.Select(f => f.Field).Distinct().Count() == 1 &&
                                 termCriteria.All(f => f.IsOrCriteria);

            return(areAllSameTerm
                ? TermsCriteria.Build(termCriteria[0].Field, termCriteria[0].Member, termCriteria.SelectMany(f => f.Values).Distinct())
                : null);
        }