UpdateMetadata() 공개 메소드

Updates the Metadata from tableData
is null. does not contain 43 columns.
public UpdateMetadata ( DataTable tableData ) : void
tableData System.Data.DataTable containing the new metadata.
리턴 void
예제 #1
0
        /// <summary>
        /// Refreshes the <see cref="MetadataProviderBase.Metadata"/> from an OLE DB data store.
        /// </summary>
        /// <exception cref="ArgumentNullException"><see cref="ConnectionString"/> or <see cref="SelectString"/> is set to a null or empty string.</exception>
        protected override void RefreshMetadata()
        {
            if (string.IsNullOrEmpty(m_connectionString))
            {
                throw new ArgumentNullException("ConnectionString");
            }

            if (string.IsNullOrEmpty(m_selectString))
            {
                throw new ArgumentNullException("SelectString");
            }

            OleDbConnection connection = new OleDbConnection(m_connectionString);

            try
            {
                // Open OleDb connection.
                connection.Open();

                // Update existing metadata.
                MetadataUpdater metadataUpdater = new MetadataUpdater(Metadata);
                metadataUpdater.UpdateMetadata(connection.ExecuteReader(m_selectString));
            }
            finally
            {
                if (connection != null)
                {
                    connection.Dispose();
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Refreshes the <see cref="MetadataProviderBase.Metadata"/> from a REST web service.
        /// </summary>
        /// <exception cref="ArgumentNullException"><see cref="ServiceUri"/> is set to a null or empty string.</exception>
        protected override void RefreshMetadata()
        {
            if (string.IsNullOrEmpty(m_serviceUri))
            {
                throw new ArgumentNullException("ServiceUri");
            }

            WebResponse response       = null;
            Stream      responseStream = null;

            try
            {
                // Retrieve new metadata.
                response       = WebRequest.Create(m_serviceUri).GetResponse();
                responseStream = response.GetResponseStream();

                // Update existing metadata.
                MetadataUpdater metadataUpdater = new MetadataUpdater(Metadata);
                metadataUpdater.UpdateMetadata(responseStream, m_serviceDataFormat);
            }
            finally
            {
                if (response != null)
                {
                    response.Close();
                }

                if (responseStream != null)
                {
                    responseStream.Dispose();
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Refreshes the <see cref="MetadataProviderBase.Metadata"/> from an ADO.NET based data store.
        /// </summary>
        /// <exception cref="ArgumentNullException"><see cref="ConnectionString"/> or <see cref="SelectString"/> is set to a null or empty string.</exception>
        protected override void RefreshMetadata()
        {
            if (string.IsNullOrEmpty(m_connectionString))
            {
                throw new ArgumentNullException("ConnectionString");
            }

            if (string.IsNullOrEmpty(m_selectString))
            {
                throw new ArgumentNullException("SelectString");
            }

            // Attempt to load configuration from an ADO.NET database connection
            IDbConnection connection = null;
            Dictionary <string, string> settings;
            string   assemblyName, connectionTypeName, adapterTypeName;
            Assembly assembly;
            Type     connectionType, adapterType;

            try
            {
                settings           = m_dataProviderString.ParseKeyValuePairs();
                assemblyName       = settings["AssemblyName"].ToNonNullString();
                connectionTypeName = settings["ConnectionType"].ToNonNullString();
                adapterTypeName    = settings["AdapterType"].ToNonNullString();

                if (string.IsNullOrEmpty(connectionTypeName))
                {
                    throw new InvalidOperationException("Database connection type was not defined");
                }

                if (string.IsNullOrEmpty(adapterTypeName))
                {
                    throw new InvalidOperationException("Database adapter type was not defined");
                }

                assembly       = Assembly.Load(new AssemblyName(assemblyName));
                connectionType = assembly.GetType(connectionTypeName);
                adapterType    = assembly.GetType(adapterTypeName);

                // Open ADO.NET provider connection
                connection = (IDbConnection)Activator.CreateInstance(connectionType);
                connection.ConnectionString = m_connectionString;
                connection.Open();

                // Update existing metadata
                MetadataUpdater metadataUpdater = new MetadataUpdater(Metadata);
                metadataUpdater.UpdateMetadata(connection.ExecuteReader(m_selectString));
            }
            finally
            {
                if (connection != null)
                {
                    connection.Dispose();
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Refreshes the <see cref="MetadataProviderBase.Metadata"/> from an OLE DB data store.
        /// </summary>
        /// <exception cref="ArgumentNullException"><see cref="ConnectionString"/> or <see cref="SelectString"/> is set to a null or empty string.</exception>
        protected override void RefreshMetadata()
        {
            if (string.IsNullOrEmpty(m_connectionString))
                throw new ArgumentNullException("ConnectionString");

            if (string.IsNullOrEmpty(m_selectString))
                throw new ArgumentNullException("SelectString");

            OleDbConnection connection = new OleDbConnection(m_connectionString);

            try
            {
                // Open OleDb connection.
                connection.Open();

                // Update existing metadata.
                MetadataUpdater metadataUpdater = new MetadataUpdater(Metadata);
                metadataUpdater.UpdateMetadata(connection.ExecuteReader(m_selectString));
            }
            finally
            {
                if (connection != null)
                    connection.Dispose();
            }
        }
예제 #5
0
        /// <summary>
        /// Refreshes the <see cref="MetadataProviderBase.Metadata"/> from a REST web service.
        /// </summary>
        /// <exception cref="ArgumentNullException"><see cref="ServiceUri"/> is set to a null or empty string.</exception>
        protected override void RefreshMetadata()
        {
            if (string.IsNullOrEmpty(m_serviceUri))
                throw new ArgumentNullException("ServiceUri");

            WebResponse response = null;
            Stream responseStream = null;
            try
            {
                // Retrieve new metadata.
                response = WebRequest.Create(m_serviceUri).GetResponse();
                responseStream = response.GetResponseStream();

                // Update existing metadata.
                MetadataUpdater metadataUpdater = new MetadataUpdater(Metadata);
                metadataUpdater.UpdateMetadata(responseStream, m_serviceDataFormat);
            }
            finally
            {
                if (response != null)
                    response.Close();

                if (responseStream != null)
                    responseStream.Dispose();
            }
        }
예제 #6
0
        /// <summary>
        /// Refreshes the <see cref="MetadataProviderBase.Metadata"/> from an ADO.NET based data store.
        /// </summary>
        /// <exception cref="ArgumentNullException"><see cref="ConnectionString"/> or <see cref="SelectString"/> is set to a null or empty string.</exception>
        protected override void RefreshMetadata()
        {
            if (string.IsNullOrEmpty(m_connectionString))
                throw new ArgumentNullException("ConnectionString");

            if (string.IsNullOrEmpty(m_selectString))
                throw new ArgumentNullException("SelectString");
            
            // Attempt to load configuration from an ADO.NET database connection
            IDbConnection connection = null;
            Dictionary<string, string> settings;
            string assemblyName, connectionTypeName, adapterTypeName;
            Assembly assembly;
            Type connectionType, adapterType;

            try
            {
                settings = m_dataProviderString.ParseKeyValuePairs();
                assemblyName = settings["AssemblyName"].ToNonNullString();
                connectionTypeName = settings["ConnectionType"].ToNonNullString();
                adapterTypeName = settings["AdapterType"].ToNonNullString();

                if (string.IsNullOrEmpty(connectionTypeName))
                    throw new InvalidOperationException("Database connection type was not defined");

                if (string.IsNullOrEmpty(adapterTypeName))
                    throw new InvalidOperationException("Database adapter type was not defined");

                assembly = Assembly.Load(new AssemblyName(assemblyName));
                connectionType = assembly.GetType(connectionTypeName);
                adapterType = assembly.GetType(adapterTypeName);

                // Open ADO.NET provider connection
                connection = (IDbConnection)Activator.CreateInstance(connectionType);
                connection.ConnectionString = m_connectionString;
                connection.Open();

                // Update existing metadata
                MetadataUpdater metadataUpdater = new MetadataUpdater(Metadata);
                metadataUpdater.UpdateMetadata(connection.ExecuteReader(m_selectString));
            }
            finally
            {
                if (connection != null)
                    connection.Dispose();
            }
        }