Exemplo n.º 1
0
        public static ExpressionStarter <ResCurrentType> Build(ResourceSearchExpressionTrees <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType> Search, ExpressionStarter <ResCurrentType> NewPredicate, SearchParameterBase SearchItem)
        {
            if (SearchItem is SearchParameterQuantity)
            {
                var SearchTypeNumber = SearchItem as SearchParameterQuantity;
                foreach (var SearchValue in SearchTypeNumber.ValueList)
                {
                    if (SearchTypeNumber.Modifier.HasValue == false)
                    {
                        if (SearchValue.Prefix.HasValue == false)
                        {
                            NewPredicate = CollectionEqualToPredicate(Search, NewPredicate, SearchTypeNumber, SearchValue);
                        }
                        else
                        {
                            switch (SearchValue.Prefix)
                            {
                            case SearchParameter.SearchComparator.Eq:
                                NewPredicate = CollectionEqualToPredicate(Search, NewPredicate, SearchTypeNumber, SearchValue);
                                break;

                            case SearchParameter.SearchComparator.Ne:
                                NewPredicate = CollectionNotEqualToPredicate(Search, NewPredicate, SearchTypeNumber, SearchValue);
                                break;

                            case SearchParameter.SearchComparator.Gt:
                                NewPredicate = NewPredicate.Or(Search.QuantityCollectionAnyGreaterThan(SearchTypeNumber.Id, SearchValue.Value, SearchValue.System, SearchValue.Code));
                                break;

                            case SearchParameter.SearchComparator.Lt:
                                NewPredicate = NewPredicate.Or(Search.QuantityCollectionAnyLessThan(SearchTypeNumber.Id, SearchValue.Value, SearchValue.System, SearchValue.Code));
                                break;

                            case SearchParameter.SearchComparator.Ge:
                                NewPredicate = NewPredicate.Or(Search.QuantityCollectionAnyGreaterThanOrEqualTo(SearchTypeNumber.Id, SearchValue.Value, SearchValue.System, SearchValue.Code));
                                break;

                            case SearchParameter.SearchComparator.Le:
                                NewPredicate = NewPredicate.Or(Search.QuantityCollectionAnyLessThanOrEqualTo(SearchTypeNumber.Id, SearchValue.Value, SearchValue.System, SearchValue.Code));
                                break;

                            case SearchParameter.SearchComparator.Sa:
                                throw new FormatException($"The search prefix: {SearchValue.Prefix.ToString()} is not supported for search parameter types of Quantity.");

                            case SearchParameter.SearchComparator.Eb:
                                throw new FormatException($"The search prefix: {SearchValue.Prefix.ToString()} is not supported for search parameter types of Quantity.");

                            case SearchParameter.SearchComparator.Ap:
                                throw new FormatException($"The search prefix: {SearchValue.Prefix.ToString()} is not supported for search parameter types of Quantity.");

                            default:
                                throw new System.ComponentModel.InvalidEnumArgumentException(SearchValue.Prefix.Value.GetLiteral(), (int)SearchValue.Prefix, typeof(SearchParameter.SearchComparator));
                            }
                        }
                    }
                    else
                    {
                        switch (SearchTypeNumber.Modifier)
                        {
                        case SearchParameter.SearchModifierCode.Missing:
                            if (SearchValue.Prefix.HasValue == false)
                            {
                                if (SearchValue.IsMissing)
                                {
                                    NewPredicate = NewPredicate.Or(Search.SearchParameterIsNull <ResIndexQuantityType>(SearchTypeNumber.Id));
                                }
                                else
                                {
                                    NewPredicate = NewPredicate.Or(Search.SearchParameterIdIsNotNull <ResIndexQuantityType>(SearchTypeNumber.Id));
                                }
                            }
                            else
                            {
                                switch (SearchValue.Prefix)
                                {
                                case SearchParameter.SearchComparator.Eq:
                                    throw new FormatException($"The search prefix: {SearchValue.Prefix.ToString()} is not supported for search parameter types of Quantity with a Modifier of: {SearchTypeNumber.Modifier.ToString()}.");

                                case SearchParameter.SearchComparator.Ne:
                                    throw new FormatException($"The search prefix: {SearchValue.Prefix.ToString()} is not supported for search parameter types of Quantity with a Modifier of: {SearchTypeNumber.Modifier.ToString()}.");

                                case SearchParameter.SearchComparator.Gt:
                                    throw new FormatException($"The search prefix: {SearchValue.Prefix.ToString()} is not supported for search parameter types of Quantity with a Modifier of: {SearchTypeNumber.Modifier.ToString()}.");

                                case SearchParameter.SearchComparator.Lt:
                                    throw new FormatException($"The search prefix: {SearchValue.Prefix.ToString()} is not supported for search parameter types of Quantity with a Modifier of: {SearchTypeNumber.Modifier.ToString()}.");

                                case SearchParameter.SearchComparator.Ge:
                                    throw new FormatException($"The search prefix: {SearchValue.Prefix.ToString()} is not supported for search parameter types of Quantity with a Modifier of: {SearchTypeNumber.Modifier.ToString()}.");

                                case SearchParameter.SearchComparator.Le:
                                    throw new FormatException($"The search prefix: {SearchValue.Prefix.ToString()} is not supported for search parameter types of Quantity with a Modifier of: {SearchTypeNumber.Modifier.ToString()}.");

                                case SearchParameter.SearchComparator.Sa:
                                    throw new FormatException($"The search prefix: {SearchValue.Prefix.ToString()} is not supported for search parameter types of Quantity with a Modifier of: {SearchTypeNumber.Modifier.ToString()}.");

                                case SearchParameter.SearchComparator.Eb:
                                    throw new FormatException($"The search prefix: {SearchValue.Prefix.ToString()} is not supported for search parameter types of Quantity with a Modifier of: {SearchTypeNumber.Modifier.ToString()}.");

                                case SearchParameter.SearchComparator.Ap:
                                    throw new FormatException($"The search prefix: {SearchValue.Prefix.ToString()} is not supported for search parameter types of Quantity with a Modifier of: {SearchTypeNumber.Modifier.ToString()}.");

                                default:
                                    throw new System.ComponentModel.InvalidEnumArgumentException(SearchValue.Prefix.Value.GetLiteral(), (int)SearchValue.Prefix, typeof(SearchParameter.SearchComparator));
                                }
                            }
                            break;

                        case SearchParameter.SearchModifierCode.Exact:
                            throw new FormatException($"The search modifier: {SearchTypeNumber.Modifier.ToString()} is not supported for search parameter types of date.");

                        case SearchParameter.SearchModifierCode.Contains:
                            throw new FormatException($"The search modifier: {SearchTypeNumber.Modifier.ToString()} is not supported for search parameter types of date.");

                        case SearchParameter.SearchModifierCode.Text:
                            throw new FormatException($"The search modifier: {SearchTypeNumber.Modifier.ToString()} is not supported for search parameter types of date.");

                        case SearchParameter.SearchModifierCode.Type:
                            throw new FormatException($"The search modifier: {SearchTypeNumber.Modifier.ToString()} is not supported for search parameter types of date.");

                        case SearchParameter.SearchModifierCode.Below:
                            throw new FormatException($"The search modifier: {SearchTypeNumber.Modifier.ToString()} is not supported for search parameter types of date.");

                        case SearchParameter.SearchModifierCode.Above:
                            throw new FormatException($"The search modifier: {SearchTypeNumber.Modifier.ToString()} is not supported for search parameter types of date.");

                        case SearchParameter.SearchModifierCode.In:
                            throw new FormatException($"The search modifier: {SearchTypeNumber.Modifier.ToString()} is not supported for search parameter types of date.");

                        case SearchParameter.SearchModifierCode.NotIn:
                            throw new FormatException($"The search modifier: {SearchTypeNumber.Modifier.ToString()} is not supported for search parameter types of date.");

                        default:
                            throw new System.ComponentModel.InvalidEnumArgumentException(SearchTypeNumber.Modifier.Value.GetLiteral(), (int)SearchTypeNumber.Modifier, typeof(SearchParameter.SearchModifierCode));
                        }
                    }
                }
            }
            return(NewPredicate);
        }