Пример #1
0
        public void GenerateAbtractObjectClass(string classNamespace, string objectSchema, string objectName)
        {
            string className            = string.Format("__{0}", renameDotNetReservedNames(objectName));
            List <sql.DBColumn> columns = new sql.DataAccess(_connectionString).GetColumns(
                objectSchema, objectName, _columnLanguageTypeValues, _columnDataProviderTypeValues);

            var    abstractClassTemplate = new sql.AbstractObjectClass(classNamespace, objectSchema, objectName, className, columns);
            string classText             = abstractClassTemplate.TransformText();

            File.WriteAllText(string.Format("{0}\\{1}.cs", _outputFolder, className), classText);
        }
Пример #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);
        }
Пример #3
0
        public void GenerateDalInterface(string classNamespace, string interfaceNamespace, string objectSchema, string objectName)
        {
            string className            = string.Format("{0}DAL", renameDotNetReservedNames(objectName));
            string interfaceName        = string.Format("I{0}", className);
            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 DAL interface created.", objectSchema, objectName));
            }
            var    interfaceTemplate = new sql.DALInterface(objectSchema, renameDotNetReservedNames(objectName), columns, classNamespace, interfaceNamespace, interfaceName);
            string interfaceText     = interfaceTemplate.TransformText();

            File.WriteAllText(string.Format("{0}\\{1}.Auto.cs", _outputFolder, interfaceName), interfaceText);
        }
Пример #4
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);
 }
Пример #5
0
 public void GenerateDal(string objectSchema, string objectName, string classNamespace, string dalNamespace, string dalConnectionKey, bool includeInterface)
 {
     string className = string.Format("{0}DAL", renameDotNetReservedNames(objectName));
     string interfaceName = string.Empty;
     if (includeInterface) interfaceName = string.Format("I{0}", className);
     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 DAL created.", objectSchema, objectName));
     var dalTemplate = new sql.DAL(objectSchema, objectName, renameDotNetReservedNames(objectName), className, classNamespace, dalNamespace, interfaceName, dalConnectionKey, columns);
     string classText = dalTemplate.TransformText();
     File.WriteAllText(string.Format("{0}\\{1}.Auto.cs", _outputFolder, className), classText);
 }
Пример #6
0
        public void GenerateAbtractObjectClass(string classNamespace, string objectSchema, string objectName)
        {
            string className = string.Format("__{0}", renameDotNetReservedNames(objectName));
            List<sql.DBColumn> columns = new sql.DataAccess(_connectionString).GetColumns(
                objectSchema, objectName, _columnLanguageTypeValues, _columnDataProviderTypeValues);

            var abstractClassTemplate = new sql.AbstractObjectClass(classNamespace, objectSchema, objectName, className, columns);
            string classText = abstractClassTemplate.TransformText();
            File.WriteAllText(string.Format("{0}\\{1}.cs", _outputFolder, className), classText);
        }