Example #1
0
        /// <summary>
        /// Prepares to import the given table valued function <paramref name="tableValuedFunction"/> as <see cref="TableInfo"/> / <see cref="ColumnInfo"/> references in the
        /// <paramref name="repository"/>.
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="tableValuedFunction"></param>
        /// <param name="usageContext"></param>
        public TableValuedFunctionImporter(ICatalogueRepository repository, DiscoveredTableValuedFunction tableValuedFunction, DataAccessContext usageContext = DataAccessContext.Any)
        {
            _repository          = repository;
            _tableValuedFunction = tableValuedFunction;
            _server   = _tableValuedFunction.Database.Server.Name;
            _database = _tableValuedFunction.Database.GetRuntimeName();
            _schema   = tableValuedFunction.Schema;

            _usageContext = usageContext;

            if (!_tableValuedFunction.Exists())
            {
                throw new Exception("Could not find tableValuedFunction with name '" + _tableValuedFunction.GetRuntimeName() + "' (.Exists() returned false)");
            }

            _tableValuedFunctionName = _tableValuedFunction.GetRuntimeName();

            _parameters = _tableValuedFunction.DiscoverParameters();

            ParametersCreated = new List <AnyTableSqlParameter>();
        }
 public override void DropFunction(DbConnection connection, DiscoveredTableValuedFunction functionToDrop)
 {
     using (SqlCommand cmd = new SqlCommand($"DROP FUNCTION {functionToDrop.Schema??"dbo"}.{functionToDrop.GetRuntimeName()}", (SqlConnection)connection))
         cmd.ExecuteNonQuery();
 }
        public override void DropFunction(DbConnection connection, DiscoveredTableValuedFunction functionToDrop)
        {
            SqlCommand cmd = new SqlCommand("DROP FUNCTION " + functionToDrop.GetRuntimeName(), (SqlConnection)connection);

            cmd.ExecuteNonQuery();
        }