public StructureDiscoveryCommand Instantiate(Target target, TargetType type, IEnumerable<CaptionFilter> filters)
        {
            if (!(connection is AdomdConnection))
                throw new ArgumentException();

            var builder = InstantiateBuilder(target, type);
            builder.Build(filters);

            var cmd = connection.CreateCommand();
            cmd.CommandText = builder.GetCommandText();
            var postFilters = builder.GetPostFilters();

            var description = new CommandDescription(target, filters);

            OlapCommand command = null;
            if ((target == Target.MeasureGroups && type == TargetType.Object) || target == Target.Perspectives)
                command = new DistinctOlapCommand(cmd, postFilters, description);
            else if (target == Target.Dimensions && type == TargetType.Object)
                command = new DimensionCommand(cmd, postFilters, description);
            else if (target == Target.Dimensions && type == TargetType.Relation)
                command = new DimensionRelationCommand(cmd, postFilters, description);
            else
                command = new OlapCommand(cmd, postFilters, description);

            return command;
        }
Exemple #2
0
        public StructureDiscoveryCommand Instantiate(Target target, TargetType type, IEnumerable <IFilter> filters)
        {
            if (!(connection is AdomdConnection))
            {
                throw new ArgumentException();
            }

            var builder = InstantiateBuilder(target, type);

            builder.Build(filters);

            var cmd = connection.CreateCommand();

            cmd.CommandText = builder.GetCommandText();
            var postFilters = builder.GetPostFilters();

            var description = new CommandDescription(target, filters);

            OlapCommand command = null;

            if ((target == Target.MeasureGroups && type == TargetType.Object) || target == Target.Perspectives)
            {
                command = new DistinctOlapCommand(cmd, postFilters, description);
            }
            else if (target == Target.Dimensions && type == TargetType.Object)
            {
                command = new DimensionCommand(cmd, postFilters, description);
            }
            else if (target == Target.Dimensions && type == TargetType.Relation)
            {
                command = new DimensionRelationCommand(cmd, postFilters, description);
            }
            else
            {
                command = new OlapCommand(cmd, postFilters, description);
            }

            return(command);
        }