private IDataSourceAdapter Create(IMongoDbSourceAdapterConfiguration configuration)
        {
            Guard.NotNull("configuration", configuration);

            if (String.IsNullOrEmpty(configuration.ConnectionString))
            {
                throw Errors.ConnectionStringMissing();
            }

            if (String.IsNullOrEmpty(configuration.Collection))
            {
                throw Errors.CollectionNameMissing();
            }

            if (!String.IsNullOrEmpty(configuration.QueryFile) && !String.IsNullOrEmpty(configuration.Query))
            {
                throw Errors.AmbiguousQuery();
            }

            if (!String.IsNullOrEmpty(configuration.ProjectionFile) && !String.IsNullOrEmpty(configuration.Projection))
            {
                throw Errors.AmbiguousProjection();
            }

            var adapter = new MongoDbSourceAdapter(GetInstanceConfiguration(configuration));

            adapter.Initialize();
            return(adapter);
        }
        private static string GetQuery(IDocumentDbSourceAdapterConfiguration configuration)
        {
            var isQuerySet     = !String.IsNullOrEmpty(configuration.Query);
            var isQueryFileSet = !String.IsNullOrEmpty(configuration.QueryFile);

            if (isQuerySet && isQueryFileSet)
            {
                throw Errors.AmbiguousQuery();
            }

            return(isQueryFileSet ? File.ReadAllText(configuration.QueryFile) : configuration.Query);
        }
Exemplo n.º 3
0
        private static string GetQuery(ISqlDataSourceAdapterConfiguration configuration)
        {
            var isQuerySet     = !String.IsNullOrEmpty(configuration.Query);
            var isQueryFileSet = !String.IsNullOrEmpty(configuration.QueryFile);

            if (isQuerySet && isQueryFileSet)
            {
                throw Errors.AmbiguousQuery();
            }

            var query = isQueryFileSet ? File.ReadAllText(configuration.QueryFile) : configuration.Query;

            if (String.IsNullOrEmpty(query))
            {
                throw Errors.QueryMissing();
            }

            return(query);
        }