Beispiel #1
0
        public PollVotingRecordQuery WithSelectedItem(PollChoiceItem value        = null,
                                                      ArgumentEvaluationMode mode = ArgumentEvaluationMode.IgnoreNeutral,
                                                      EntityOperator @operator    = EntityOperator.Equal)
        {
            switch (mode)
            {
            case ArgumentEvaluationMode.IgnoreNeutral:
                if (Neutrals.Is(value))
                {
                    return(this);
                }
                break;

            case ArgumentEvaluationMode.Explicit:
                break;

            default:
                throw new NotSupportedEnumException(mode);
            }

            switch (@operator)
            {
            case EntityOperator.Equal:
                Entities = Entities.Where(pvr => pvr.SelectedItem == value);
                return(this);

            case EntityOperator.NotEqual:
                Entities = Entities.Where(pvr => pvr.SelectedItem != value);
                return(this);

            default:
                throw new NotSupportedEnumException(@operator);
            }
        }
Beispiel #2
0
        public PollChoiceQuery WithItem(PollChoiceItem value          = null,
                                        ArgumentEvaluationMode mode   = ArgumentEvaluationMode.IgnoreNeutral,
                                        CollectionOperator @operator  = CollectionOperator.Equal,
                                        CollectionDirection direction = CollectionDirection.Any)
        {
            switch (mode)
            {
            case ArgumentEvaluationMode.IgnoreNeutral:
                if (Neutrals.Is(value))
                {
                    return(this);
                }
                break;

            case ArgumentEvaluationMode.Explicit:
                break;

            default:
                throw new NotSupportedEnumException(mode);
            }

            switch (@operator)
            {
            case CollectionOperator.Equal:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(pc => pc.Items.Any(pci => pci == value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(pc => pc.Items.All(pci => pci == value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            case CollectionOperator.NotEqual:
                switch (direction)
                {
                case CollectionDirection.Any:
                    Entities = Entities.Where(pc => pc.Items.Any(pci => pci != value));
                    return(this);

                case CollectionDirection.All:
                    Entities = Entities.Where(pc => pc.Items.All(pci => pci != value));
                    return(this);

                default:
                    throw new NotSupportedEnumException(direction);
                }

            default:
                throw new NotSupportedEnumException(@operator);
            }
        }