示例#1
0
        /// <summary>
        /// Generate a SQL Server stored procedure for the specified SQL Action (Select, Insert, Update, Delete)
        /// </summary>
        /// <param name="sqlAction"></param>
        /// <param name="objectSchema"></param>
        /// <param name="objectName"></param>
        /// <param name="getProcedureTemplate"></param>
        private void GenerateSqlServerProcedure(SqlAction sqlAction, string objectSchema, string objectName, GetProcedureTemplate getProcedureTemplate)
        {
            string procedureName        = string.Format("{0}{1}Auto", objectName, sqlAction.ToString());
            List <sql.DBColumn> columns = new sql.DataAccess(_connectionString).GetColumns(
                objectSchema, objectName, _columnLanguageTypeValues, _columnDataProviderTypeValues);

            if (!HasPrimaryKey(columns))
            {
                throw new NoPrimaryKeyException(string.Format("{0}.{1} has no primary key.  No Sql Server {2} procedure created.", objectSchema, objectName, sqlAction.ToString()));
            }
            string procText = getProcedureTemplate(objectSchema, objectName, procedureName, columns);

            File.WriteAllText(string.Format("{0}\\{1}.{2}.sql", _outputFolder, objectSchema, procedureName), procText);
        }
示例#2
0
 /// <summary>
 /// Generate a SQL Server stored procedure for the specified SQL Action (Select, Insert, Update, Delete)
 /// </summary>
 /// <param name="sqlAction"></param>
 /// <param name="objectSchema"></param>
 /// <param name="objectName"></param>
 /// <param name="getProcedureTemplate"></param>
 private void GenerateSqlServerProcedure(SqlAction sqlAction, string objectSchema, string objectName, GetProcedureTemplate getProcedureTemplate)
 {
     string procedureName = string.Format("{0}{1}Auto", objectName, sqlAction.ToString());
     List<sql.DBColumn> columns = new sql.DataAccess(_connectionString).GetColumns(
         objectSchema, objectName, _columnLanguageTypeValues, _columnDataProviderTypeValues);
     if (!HasPrimaryKey(columns)) throw new NoPrimaryKeyException(string.Format("{0}.{1} has no primary key.  No Sql Server {2} procedure created.", objectSchema, objectName, sqlAction.ToString()));
     string procText = getProcedureTemplate(objectSchema, objectName, procedureName, columns);
     File.WriteAllText(string.Format("{0}\\{1}.{2}.sql", _outputFolder, objectSchema, procedureName), procText);
 }