Exemple #1
0
        private ExpressionStarter <IResourceIndexed> PredicateSearchParameter(SearchParameterBase SearchItem)
        {
            var Search = new Search <IResourceIndexed>();
            ExpressionStarter <IResourceIndexed> Predicate = LinqKit.PredicateBuilder.New <IResourceIndexed>();

            switch (SearchItem.Type)
            {
            case SearchParamType.Date:
                Predicate = DateTimePeriodPredicateBuilder <IResourceIndexed> .Build(Search, Predicate, SearchItem);

                break;

            case SearchParamType.Number:
            {
                if (SearchItem is SearchParameterNumber)
                {
                    var SearchTypeNumber = SearchItem as SearchParameterNumber;
                    foreach (var SearchValue in SearchTypeNumber.ValueList)
                    {
                        if (SearchTypeNumber.Name != "page")
                        {
                            //ToDo: more needed here
                        }
                    }
                }
                Predicate = NumberPredicateBuilder <IResourceIndexed> .Build(Search, Predicate, SearchItem);
            }
            break;

            case SearchParamType.Quantity:
                Predicate = QuantityPredicateBuilder <IResourceIndexed> .Build(Search, Predicate, SearchItem);

                break;

            case SearchParamType.Reference:
                Predicate = ReferancePredicateBuilder <IResourceIndexed> .Build(Search, Predicate, SearchItem, IPrimaryServiceRootCache.GetPrimaryRootUrlStoreFromDatabase());

                break;

            case SearchParamType.String:
                Predicate = StringPredicateBuilder <IResourceIndexed> .Build(Search, Predicate, SearchItem);

                break;

            case SearchParamType.Token:
                Predicate = TokenPredicateBuilder <IResourceIndexed> .Build(Search, Predicate, SearchItem);

                break;

            case SearchParamType.Uri:
                Predicate = UriPredicateBuilder <IResourceIndexed> .Build(Search, Predicate, SearchItem);

                break;

            default:
                throw new System.ComponentModel.InvalidEnumArgumentException(SearchItem.Type.ToString(), (int)SearchItem.Type, typeof(SearchParamType));
            }
            return(Predicate);
        }
Exemple #2
0
        protected ExpressionStarter <ResCurrentType> PredicateSearchParameter <
            ResCurrentType,
            ResIndexStringType,
            ResIndexTokenType,
            ResIndexUriType,
            ResIndexReferenceType,
            ResIndexQuantityType,
            ResIndexDateTimeType>(SearchParameterBase SearchItem)
            where ResCurrentType : ResourceCurrentBase <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexStringType : ResourceIndexString <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexTokenType : ResourceIndexToken <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexUriType : ResourceIndexUri <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>, new()
            where ResIndexReferenceType : ResourceIndexReference <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexQuantityType : ResourceIndexQuantity <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
            where ResIndexDateTimeType : ResourceIndexDateTime <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>
        {
            var Search = new ResourceSearch <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType>();
            ExpressionStarter <ResCurrentType> Predicate = LinqKit.PredicateBuilder.New <ResCurrentType>();

            switch (SearchItem.Type)
            {
            case SearchParamType.Date:
                Predicate = DateTimePeriodPredicateBuilder <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType> .Build(Search, Predicate, SearchItem);

                break;

            case SearchParamType.Number:
            {
                if (SearchItem is SearchParameterNumber)
                {
                    var SearchTypeNumber = SearchItem as SearchParameterNumber;
                    foreach (var SearchValue in SearchTypeNumber.ValueList)
                    {
                        if (SearchTypeNumber.Name != "page")
                        {
                            //ToDo: more needed here
                        }
                    }
                }
                Predicate = NumberPredicateBuilder <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType> .Build(Search, Predicate, SearchItem);
            }
            break;

            case SearchParamType.Quantity:
                Predicate = QuantityPredicateBuilder <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType> .Build(Search, Predicate, SearchItem);

                break;

            case SearchParamType.Reference:
                Predicate = ReferancePredicateBuilder <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType> .Build(Search, Predicate, SearchItem, IPrimaryServiceRootCache.GetPrimaryRootUrlFromDatabase());

                break;

            case SearchParamType.String:
                Predicate = StringPredicateBuilder <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType> .Build(Search, Predicate, SearchItem);

                break;

            case SearchParamType.Token:
                Predicate = TokenPredicateBuilder <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType> .Build(Search, Predicate, SearchItem);

                break;

            case SearchParamType.Uri:
                Predicate = UriPredicateBuilder <ResCurrentType, ResIndexStringType, ResIndexTokenType, ResIndexUriType, ResIndexReferenceType, ResIndexQuantityType, ResIndexDateTimeType> .Build(Search, Predicate, SearchItem);

                break;

            default:
                throw new System.ComponentModel.InvalidEnumArgumentException(SearchItem.Type.ToString(), (int)SearchItem.Type, typeof(SearchParamType));
            }
            return(Predicate);
        }