Пример #1
0
        private bool IsColumnValidForInsert(DBColumn column)
        {
            bool isValid = false;

            if (!DataAccess.isModifiedDate(column) && !DataAccess.isCreatedDate(column) && !DataAccess.isAuthorityId(column))
            {
                isValid = !column.IsAutoKey && !column.IsComputed;
            }
            return(isValid);
        }
Пример #2
0
        public static bool isCreatedDate(DBColumn column)
        {
            if ((column.Name.ToLower() == "createddate" &&
                 column.DataTypeName.ToLower() == "datetime") ||
                (column.Name.ToLower() == "creationdate" &&
                 column.DataTypeName.ToLower() == "datetime"))

            /* -- Could use this as well, but need to extend DBColumn and DataAccess.GetColumns() to read column description metadata
            ||
            || (column.Description.ToLower().StartsWith("createddate") &&
            || column.DataTypeName.ToLower() == "datetime") ||
            || (column.Description.ToLower().StartsWith("creationdate") &&
            || column.DataTypeName.ToLower() == "datetime"))
            */
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        public List <DBColumn> GetColumns(string objectSchema, string objectName, Dictionary <string, string> languageTypes,
                                          Dictionary <string, string> dataProviders)
        {
            string MAXsize = "1073741823";

            SqlConnection connection = new SqlConnection(_connectionString);

            connection.Open();

            SqlCommand command = new SqlCommand();

            command.Connection  = connection;
            command.CommandType = System.Data.CommandType.Text;
            command.CommandText = "SELECT c.COLUMN_NAME, " +
                                  "c.ORDINAL_POSITION, " +
                                  "c.DATA_TYPE, " +
                                  "CASE WHEN c.CHARACTER_MAXIMUM_LENGTH = -1 THEN " + MAXsize + " ELSE c.CHARACTER_MAXIMUM_LENGTH END AS CHARACTER_MAXIMUM_LENGTH, " +
                                  "c.NUMERIC_PRECISION, " +
                                  "c.NUMERIC_SCALE, " +
                                  "MAX(CASE WHEN tc.CONSTRAINT_TYPE = 'PRIMARY KEY' THEN 1 ELSE 0 END) AS IS_IN_PRIMARY_KEY, " +
                                  "CASE WHEN fk.COLUMN_NAME IS NULL THEN 0 ELSE 1 END AS IS_IN_FOREIGN_KEY, " +
                                  "COLUMNPROPERTY(OBJECT_ID(c.TABLE_SCHEMA + '.' + c.TABLE_NAME), c.COLUMN_NAME,'IsComputed') AS IS_COMPUTED, " +
                                  "COLUMNPROPERTY(OBJECT_ID(c.TABLE_SCHEMA + '.' + c.TABLE_NAME), c.COLUMN_NAME,'IsIdentity') AS IS_IDENTITY, " +
                                  "c.IS_NULLABLE " +
                                  "FROM    INFORMATION_SCHEMA.COLUMNS c " +
                                  "LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu " +
                                  "ON c.TABLE_SCHEMA = cu.TABLE_SCHEMA " +
                                  "AND c.TABLE_NAME = cu.TABLE_NAME " +
                                  "AND c.COLUMN_NAME = cu.COLUMN_NAME " +
                                  "LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc " +
                                  "ON tc.CONSTRAINT_TYPE IN ('PRIMARY KEY', 'FOREIGN KEY') " +
                                  "AND tc.TABLE_SCHEMA = cu.TABLE_SCHEMA " +
                                  "AND tc.TABLE_NAME = cu.TABLE_NAME " +
                                  "AND tc.CONSTRAINT_NAME = cu.CONSTRAINT_NAME " +

                                  "LEFT JOIN ( " +
                                  //"--Foreign keys defined on the target table " +
                                  "SELECT DISTINCT s1.name AS TABLE_SCHEMA, o1.name AS TABLE_NAME, c1.name AS COLUMN_NAME " +
                                  "FROM    sys.objects o1 " +
                                  "INNER JOIN sys.foreign_keys fk ON o1.object_id = fk.parent_object_id " +
                                  "INNER JOIN sys.foreign_key_columns fkc ON fk.object_id = fkc.constraint_object_id " +
                                  "INNER JOIN sys.columns c1 ON fkc.parent_object_id = c1.object_id AND fkc.parent_column_id = c1.column_id " +
                                  "INNER JOIN sys.schemas s1 ON s1.schema_id = o1.schema_id " +
                                  "UNION " +
                                  //"-- Foreign keys defined on other tables that reference the target table " +
                                  "SELECT DISTINCT s2.name, o2.name, c2.name " +
                                  "FROM    sys.objects o1 " +
                                  "INNER JOIN sys.foreign_keys fk ON o1.object_id = fk.parent_object_id " +
                                  "INNER JOIN sys.foreign_key_columns fkc ON fk.object_id = fkc.constraint_object_id " +
                                  "INNER JOIN sys.columns c2 ON fkc.referenced_object_id = c2.object_id AND fkc.referenced_column_id = c2.column_id " +
                                  "INNER JOIN sys.objects o2 ON fk.referenced_object_id = o2.object_id " +
                                  "INNER JOIN sys.schemas s2 ON s2.schema_id = o2.schema_id " +
                                  ") AS fk " +
                                  "ON c.TABLE_SCHEMA = fk.TABLE_SCHEMA " +
                                  "AND c.TABLE_NAME = fk.TABLE_NAME " +
                                  "AND c.COLUMN_NAME = fk.COLUMN_NAME " +

                                  "WHERE c.TABLE_SCHEMA = '" + objectSchema + "' " +
                                  "AND c.TABLE_NAME = '" + objectName + "' " +

                                  "GROUP BY " +
                                  "c.COLUMN_NAME,  " +
                                  "c.ORDINAL_POSITION, " +
                                  "c.DATA_TYPE,  " +
                                  "c.CHARACTER_MAXIMUM_LENGTH,  " +
                                  "c.NUMERIC_PRECISION,  " +
                                  "c.NUMERIC_SCALE,  " +
                                  "CASE WHEN fk.COLUMN_NAME IS NULL THEN 0 ELSE 1 END,  " +
                                  "COLUMNPROPERTY(OBJECT_ID(c.TABLE_SCHEMA + '.' + c.TABLE_NAME), c.COLUMN_NAME, 'IsComputed'),  " +
                                  "COLUMNPROPERTY(OBJECT_ID(c.TABLE_SCHEMA + '.' + c.TABLE_NAME), c.COLUMN_NAME, 'IsIdentity'),  " +
                                  "c.IS_NULLABLE " +

                                  "ORDER BY c.ORDINAL_POSITION";

            SqlDataReader reader = command.ExecuteReader();

            List <DBColumn> columns = new List <DBColumn>();

            while (reader.Read())
            {
                DBColumn column = new DBColumn();
                column.Name           = reader.GetString(reader.GetOrdinal("COLUMN_NAME"));
                column.Alias          = createAlias(column.Name);
                column.Ordinal        = reader.GetInt32(reader.GetOrdinal("ORDINAL_POSITION"));
                column.IsInPrimaryKey = (reader.GetInt32(reader.GetOrdinal("IS_IN_PRIMARY_KEY")) == 1);
                column.IsInForeignKey = (reader.GetInt32(reader.GetOrdinal("IS_IN_FOREIGN_KEY")) == 1);
                string dataType         = reader.GetString(reader.GetOrdinal("DATA_TYPE"));
                string characterMaximum = string.Empty;
                if (!reader.IsDBNull(reader.GetOrdinal("CHARACTER_MAXIMUM_LENGTH")))
                {
                    characterMaximum = reader.GetInt32(reader.GetOrdinal("CHARACTER_MAXIMUM_LENGTH")).ToString();
                }
                column.NumericPrecision = (reader.IsDBNull(reader.GetOrdinal("NUMERIC_PRECISION"))) ? 0 : Convert.ToInt32(reader.GetByte(reader.GetOrdinal("NUMERIC_PRECISION")));
                column.NumericScale     = (reader.IsDBNull(reader.GetOrdinal("NUMERIC_SCALE"))) ? 0 : reader.GetInt32(reader.GetOrdinal("NUMERIC_SCALE"));

                column.DataTypeName = dataType;
                string dataTypeNameComplete = string.Empty;
                if (string.IsNullOrWhiteSpace(characterMaximum) ||
                    dataType.ToLower() == "text" ||
                    dataType.ToLower() == "ntext")
                {
                    dataTypeNameComplete = dataType;
                }
                else
                {
                    if (characterMaximum == MAXsize)
                    {
                        dataTypeNameComplete = string.Format("{0}(MAX)", dataType);
                    }
                    else
                    {
                        dataTypeNameComplete = string.Format("{0}({1})", dataType, characterMaximum);
                    }
                }
                column.DataTypeNameComplete = dataTypeNameComplete;

                column.LanguageType       = languageTypes[dataType];
                column.DataProviderType   = dataProviders[dataType];
                column.CharacterMaxLength = (string.IsNullOrWhiteSpace(characterMaximum)) ? column.CharacterMaxLength : Convert.ToInt32(characterMaximum);
                column.IsComputed         = (reader.GetInt32(reader.GetOrdinal("IS_COMPUTED")) == 1);
                column.IsAutoKey          = (reader.GetInt32(reader.GetOrdinal("IS_IDENTITY")) == 1);
                column.IsNullable         = (reader.GetString(reader.GetOrdinal("IS_NULLABLE")) == "YES");
                columns.Add(column);
            }

            return(columns);
        }
Пример #4
0
 public static bool isCreationUserId(DBColumn column)
 {
     return column.Name.ToLower() == "creationuserid" && column.DataTypeName.ToLower() == "int";
 }
Пример #5
0
 public static bool isAuthorityId(DBColumn column)
 {
     return column.Name.ToLower() == "authorityid" && column.DataTypeName.ToLower() == "int";
 }
Пример #6
0
        public List<DBColumn> GetColumns(string objectSchema, string objectName, Dictionary<string, string> languageTypes, 
            Dictionary<string, string> dataProviders)
        {
            SqlConnection connection = new SqlConnection(_connectionString);
            connection.Open();

            SqlCommand command = new SqlCommand();
            command.Connection = connection;
            command.CommandType = System.Data.CommandType.Text;
            command.CommandText = "SELECT c.COLUMN_NAME, " +
                                        "c.ORDINAL_POSITION, " +
                                        "c.DATA_TYPE, " +
                                        "CASE WHEN c.CHARACTER_MAXIMUM_LENGTH = -1 THEN 1073741823 ELSE c.CHARACTER_MAXIMUM_LENGTH END AS CHARACTER_MAXIMUM_LENGTH, " +
                                        "c.NUMERIC_PRECISION, " +
		                                "c.NUMERIC_SCALE, " +
                                        "MAX(CASE WHEN tc.CONSTRAINT_TYPE = 'PRIMARY KEY' THEN 1 ELSE 0 END) AS IS_IN_PRIMARY_KEY, " +
                                        "CASE WHEN fk.COLUMN_NAME IS NULL THEN 0 ELSE 1 END AS IS_IN_FOREIGN_KEY, " +
                                        "COLUMNPROPERTY(OBJECT_ID(c.TABLE_SCHEMA + '.' + c.TABLE_NAME), c.COLUMN_NAME,'IsComputed') AS IS_COMPUTED, " +
                                        "COLUMNPROPERTY(OBJECT_ID(c.TABLE_SCHEMA + '.' + c.TABLE_NAME), c.COLUMN_NAME,'IsIdentity') AS IS_IDENTITY, " +
                                        "c.IS_NULLABLE " +
                                "FROM    INFORMATION_SCHEMA.COLUMNS c " +
                                        "LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE cu " +
                                            "ON c.TABLE_SCHEMA = cu.TABLE_SCHEMA " +
                                            "AND c.TABLE_NAME = cu.TABLE_NAME " +
                                            "AND c.COLUMN_NAME = cu.COLUMN_NAME " +
                                        "LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc " +
                                            "ON tc.CONSTRAINT_TYPE IN ('PRIMARY KEY', 'FOREIGN KEY') " +
                                            "AND tc.TABLE_SCHEMA = cu.TABLE_SCHEMA " +
                                            "AND tc.TABLE_NAME = cu.TABLE_NAME " +
                                            "AND tc.CONSTRAINT_NAME = cu.CONSTRAINT_NAME " +

                                        "LEFT JOIN ( " +
                                            //"--Foreign keys defined on the target table " +
                                            "SELECT DISTINCT s1.name AS TABLE_SCHEMA, o1.name AS TABLE_NAME, c1.name AS COLUMN_NAME " +
                                            "FROM    sys.objects o1 " +
                                                    "INNER JOIN sys.foreign_keys fk ON o1.object_id = fk.parent_object_id " +
                                                    "INNER JOIN sys.foreign_key_columns fkc ON fk.object_id = fkc.constraint_object_id " +
                                                    "INNER JOIN sys.columns c1 ON fkc.parent_object_id = c1.object_id AND fkc.parent_column_id = c1.column_id " +
                                                    "INNER JOIN sys.schemas s1 ON s1.schema_id = o1.schema_id " +
                                            "UNION " +
                                            //"-- Foreign keys defined on other tables that reference the target table " +
                                            "SELECT DISTINCT s2.name, o2.name, c2.name " +
                                            "FROM    sys.objects o1 " +
                                                    "INNER JOIN sys.foreign_keys fk ON o1.object_id = fk.parent_object_id " +
                                                    "INNER JOIN sys.foreign_key_columns fkc ON fk.object_id = fkc.constraint_object_id " +
                                                    "INNER JOIN sys.columns c2 ON fkc.referenced_object_id = c2.object_id AND fkc.referenced_column_id = c2.column_id " +
                                                    "INNER JOIN sys.objects o2 ON fk.referenced_object_id = o2.object_id " +
                                                    "INNER JOIN sys.schemas s2 ON s2.schema_id = o2.schema_id " +
                                        ") AS fk " +
                                            "ON c.TABLE_SCHEMA = fk.TABLE_SCHEMA " +
                                            "AND c.TABLE_NAME = fk.TABLE_NAME " +
                                            "AND c.COLUMN_NAME = fk.COLUMN_NAME " +

                                "WHERE c.TABLE_SCHEMA = '" + objectSchema + "' " +
                                "AND c.TABLE_NAME = '" + objectName + "' " +

                                "GROUP BY " +
                                        "c.COLUMN_NAME,  " +
                                        "c.ORDINAL_POSITION, " +
                                        "c.DATA_TYPE,  " +
                                        "c.CHARACTER_MAXIMUM_LENGTH,  " +
                                        "c.NUMERIC_PRECISION,  " +
                                        "c.NUMERIC_SCALE,  " +
                                        "CASE WHEN fk.COLUMN_NAME IS NULL THEN 0 ELSE 1 END,  " +
                                        "COLUMNPROPERTY(OBJECT_ID(c.TABLE_SCHEMA + '.' + c.TABLE_NAME), c.COLUMN_NAME, 'IsComputed'),  " +
                                        "COLUMNPROPERTY(OBJECT_ID(c.TABLE_SCHEMA + '.' + c.TABLE_NAME), c.COLUMN_NAME, 'IsIdentity'),  " +
                                        "c.IS_NULLABLE " +

                                "ORDER BY c.ORDINAL_POSITION";

            SqlDataReader reader = command.ExecuteReader();

            List<DBColumn> columns = new List<DBColumn>();

            while (reader.Read())
            {
                DBColumn column = new DBColumn();
                column.Name = reader.GetString(reader.GetOrdinal("COLUMN_NAME"));
                column.Alias = createAlias(column.Name);
                column.Ordinal = reader.GetInt32(reader.GetOrdinal("ORDINAL_POSITION"));
                column.IsInPrimaryKey = (reader.GetInt32(reader.GetOrdinal("IS_IN_PRIMARY_KEY")) == 1);
                column.IsInForeignKey = (reader.GetInt32(reader.GetOrdinal("IS_IN_FOREIGN_KEY")) == 1);
                string dataType = reader.GetString(reader.GetOrdinal("DATA_TYPE"));
                string characterMaximum = string.Empty;
                if (!reader.IsDBNull(reader.GetOrdinal("CHARACTER_MAXIMUM_LENGTH"))) characterMaximum = reader.GetInt32(reader.GetOrdinal("CHARACTER_MAXIMUM_LENGTH")).ToString();
                column.NumericPrecision = (reader.IsDBNull(reader.GetOrdinal("NUMERIC_PRECISION"))) ? 0 : Convert.ToInt32(reader.GetByte(reader.GetOrdinal("NUMERIC_PRECISION")));
                column.NumericScale = (reader.IsDBNull(reader.GetOrdinal("NUMERIC_SCALE"))) ? 0 : reader.GetInt32(reader.GetOrdinal("NUMERIC_SCALE"));
                column.DataTypeName = dataType;
                string dataTypeNameComplete = string.IsNullOrWhiteSpace(characterMaximum) ? dataType : string.Format("{0}({1})", dataType, characterMaximum);
                column.DataTypeNameComplete = dataTypeNameComplete;
                column.LanguageType = languageTypes[dataType];
                column.DataProviderType = dataProviders[dataType];
                column.CharacterMaxLength = (string.IsNullOrWhiteSpace(characterMaximum)) ? column.CharacterMaxLength : Convert.ToInt32(characterMaximum);
                column.IsComputed = (reader.GetInt32(reader.GetOrdinal("IS_COMPUTED")) == 1);
                column.IsAutoKey = (reader.GetInt32(reader.GetOrdinal("IS_IDENTITY")) == 1);
                column.IsNullable = (reader.GetString(reader.GetOrdinal("IS_NULLABLE")) == "YES");
                columns.Add(column);
            }

            return columns;
        }
Пример #7
0
 public static bool isCreatedDate(DBColumn column)
 {
     if ((column.Name.ToLower() == "createddate" &&
         column.DataTypeName.ToLower() == "datetime") ||
         (column.Name.ToLower() == "creationdate" &&
         column.DataTypeName.ToLower() == "datetime"))
         /* -- Could use this as well, but need to extend DBColumn and DataAccess.GetColumns() to read column description metadata
         ||
         (column.Description.ToLower().StartsWith("createddate") &&
         column.DataTypeName.ToLower() == "datetime") ||
         (column.Description.ToLower().StartsWith("creationdate") &&
         column.DataTypeName.ToLower() == "datetime"))
         */
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Пример #8
0
 private bool IsColumnValidForSelect(DBColumn column)
 {
     return(column.IsInPrimaryKey);
 }
Пример #9
0
 private bool IsColumnValidForSelect(DBColumn column)
 {
     return column.IsInPrimaryKey;
 }
Пример #10
0
 private bool IsColumnValidForUpdate(DBColumn column)
 {
     return !DataAccess.isModifiedDate(column) && !DataAccess.isCreatedDate(column) &&
             !DataAccess.isAuthorityId(column) && !DataAccess.isCreationUserId(column);
 }
Пример #11
0
	private void renderSqlDelete(DBColumn[] columns, string schemaName, string objectName, string procedureName)
	{
		DateTime generated = DateTime.Now;
		StringBuilder entrySb = new StringBuilder();
		StringBuilder whereSb = new StringBuilder();
		
		int x = 0;
		
		foreach (DBColumn column in columns)
		{
			if (column.IsInPrimaryKey)
			{
				if (x > 0)
				{
					entrySb.AppendFormat(",\r\n");
					whereSb.AppendFormat(" AND\r\n");
				}
				
				entrySb.AppendFormat("@{0} {1}", column.Name, column.DataTypeNameComplete.ToUpper());
				whereSb.AppendFormat("\t[{0}] = @{0}", column.Name);

				x++;
			}
		}

		string entryString = entrySb.ToString();
		string whereString = whereSb.ToString();

		entrySb = null;
		whereSb = null;

        
        #line default
        #line hidden
        
        #line 43 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write("IF EXISTS(SELECT * FROM dbo.sysobjects WHERE id = object_id(N\'[");

        
        #line default
        #line hidden
        
        #line 44 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 44 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write("].[");

        
        #line default
        #line hidden
        
        #line 44 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(procedureName));

        
        #line default
        #line hidden
        
        #line 44 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write("]\') AND OBJECTPROPERTY(id, N\'IsProcedure\') = 1)\r\nDROP PROCEDURE [");

        
        #line default
        #line hidden
        
        #line 45 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 45 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write("].[");

        
        #line default
        #line hidden
        
        #line 45 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(procedureName));

        
        #line default
        #line hidden
        
        #line 45 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write("]\r\nGO\r\n\r\nSET QUOTED_IDENTIFIER ON\r\nGO\r\nSET ANSI_NULLS ON\r\nGO\r\n\r\n-- Delete Procedu" +
        "re for ");

        
        #line default
        #line hidden
        
        #line 53 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 53 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write(".");

        
        #line default
        #line hidden
        
        #line 53 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(objectName));

        
        #line default
        #line hidden
        
        #line 53 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write("\r\n-- Do not modify the contents of this procedure.\r\n-- Generated ");

        
        #line default
        #line hidden
        
        #line 55 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(generated.ToString()));

        
        #line default
        #line hidden
        
        #line 55 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write("\r\n\r\nCREATE PROCEDURE ");

        
        #line default
        #line hidden
        
        #line 57 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 57 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write(".");

        
        #line default
        #line hidden
        
        #line 57 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(procedureName));

        
        #line default
        #line hidden
        
        #line 57 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write("\r\n\r\n");

        
        #line default
        #line hidden
        
        #line 59 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(entryString));

        
        #line default
        #line hidden
        
        #line 59 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write("\r\n\r\nAS \r\n\r\nSET NOCOUNT ON\r\n\r\nDELETE \r\nFROM\t\r\n\t[");

        
        #line default
        #line hidden
        
        #line 67 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 67 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write("].[");

        
        #line default
        #line hidden
        
        #line 67 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(objectName));

        
        #line default
        #line hidden
        
        #line 67 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write("]\r\nWHERE\t\r\n");

        
        #line default
        #line hidden
        
        #line 69 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(whereString));

        
        #line default
        #line hidden
        
        #line 69 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write("\r\n\r\nIF @@ERROR <> 0\r\nBEGIN\r\n\t-- raiserror will throw a SqlException\r\n\tRAISERROR(\'" +
        "An error occurred in procedure ");

        
        #line default
        #line hidden
        
        #line 74 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 74 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write(".");

        
        #line default
        #line hidden
        
        #line 74 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(procedureName));

        
        #line default
        #line hidden
        
        #line 74 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
this.Write(". No information was deleted as a result of this request.\', 16, 1)\r\n\tRETURN 9 -- " +
        "error occurred \r\nEND\r\nELSE BEGIN\r\n\tRETURN 0 -- delete successful\r\nEND\r\n\r\nGO\r\n \r\n" +
        "SET QUOTED_IDENTIFIER OFF\r\nGO\r\nSET ANSI_NULLS ON\r\nGO\r\n");

        
        #line default
        #line hidden
        
        #line 87 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\DeleteProc.tt"
	
	}
Пример #12
0
private void renderAbstractClass(string classNamespace, string objectSchema, string objectName, string className, DBColumn[] tableColumns)
{
	DateTime generated = DateTime.Now;

	StringBuilder sb = new StringBuilder();
	int x = 0;
	foreach (DBColumn column in tableColumns)
	{
		if (x < tableColumns.Length)
		{
			sb.AppendFormat("{0} {1}", column.Type(), column.ParamName());				
			if (x < tableColumns.Length -1) sb.AppendFormat(", \r\n\t\t\t");
		}			
		x++;
	}		
	string constructorParms = sb.ToString();


        
        #line default
        #line hidden
        
        #line 30 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("// Generated ");

        
        #line default
        #line hidden
        
        #line 31 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(generated.ToString()));

        
        #line default
        #line hidden
        
        #line 31 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\r\n// Do not modify the contents of this code file.\r\n// This abstract class ");

        
        #line default
        #line hidden
        
        #line 33 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 33 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(" is based upon ");

        
        #line default
        #line hidden
        
        #line 33 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(objectSchema));

        
        #line default
        #line hidden
        
        #line 33 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(".");

        
        #line default
        #line hidden
        
        #line 33 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(objectName));

        
        #line default
        #line hidden
        
        #line 33 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(".\r\n\r\n#region How To Implement\r\n\r\n// To implement, create another code file as out" +
        "lined in the following example.\r\n// It is recommended the code file you create b" +
        "e in the same project as this code file.\r\n// Example:\r\n// using System;\r\n//\r\n// " +
        "namespace ");

        
        #line default
        #line hidden
        
        #line 42 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(classNamespace));

        
        #line default
        #line hidden
        
        #line 42 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\r\n// {\r\n//\t\t[Serializable]\r\n// \t\tpublic class ");

        
        #line default
        #line hidden
        
        #line 45 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(objectName));

        
        #line default
        #line hidden
        
        #line 45 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(" : ");

        
        #line default
        #line hidden
        
        #line 45 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 45 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\r\n//\t\t{\r\n//\t\t}\r\n// }\r\n\r\n#endregion How To Implement\r\n\r\n#region Using \r\n\r\nusing Sy" +
        "stem;\r\nusing System.Data;\r\nusing CustomDataAccess;\r\n\r\n#endregion Using\r\n\r\nnamesp" +
        "ace ");

        
        #line default
        #line hidden
        
        #line 60 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(classNamespace));

        
        #line default
        #line hidden
        
        #line 60 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\r\n{\r\n\t[Serializable]\r\n\tpublic abstract class ");

        
        #line default
        #line hidden
        
        #line 63 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 63 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(" : CustomObjectBase, ICloneable, IComparable, IDisposable, ISetValues\r\n\t{\r\n\t\t#reg" +
        "ion Constructors\r\n\t\t\r\n\t\t/// <summary>\r\n\t\t/// Default constructor.\r\n\t\t/// </summa" +
        "ry>\r\n\t\tpublic ");

        
        #line default
        #line hidden
        
        #line 70 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 70 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("()\r\n\t\t{\r\n\t\t}\r\n\r\n\t\t/// <summary>\r\n\t\t/// Overloaded constructor specifying each col" +
        "umn value.\r\n\t\t/// </summary>\r\n\t\t");

        
        #line default
        #line hidden
        
        #line 77 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
 foreach (DBColumn column in tableColumns)
		{
        
        #line default
        #line hidden
        
        #line 78 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("/// <param name=\"");

        
        #line default
        #line hidden
        
        #line 79 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.ParamName()));

        
        #line default
        #line hidden
        
        #line 79 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\"></param>\r\n\t\t");

        
        #line default
        #line hidden
        
        #line 80 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
}
        
        #line default
        #line hidden
        
        #line 80 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("public ");

        
        #line default
        #line hidden
        
        #line 81 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 81 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("(");

        
        #line default
        #line hidden
        
        #line 81 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(constructorParms));

        
        #line default
        #line hidden
        
        #line 81 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(") : this()\r\n\t\t{\r\n\t\t");

        
        #line default
        #line hidden
        
        #line 83 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
 foreach (DBColumn column in tableColumns)
		{
        
        #line default
        #line hidden
        
        #line 84 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\t");

        
        #line default
        #line hidden
        
        #line 85 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.SetName()));

        
        #line default
        #line hidden
        
        #line 85 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(" = ");

        
        #line default
        #line hidden
        
        #line 85 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.ParamName()));

        
        #line default
        #line hidden
        
        #line 85 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(";\r\n\t\t");

        
        #line default
        #line hidden
        
        #line 86 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
}
        
        #line default
        #line hidden
        
        #line 86 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("}\r\n\t\t\r\n\t\t#endregion Constructors\r\n\t\t\r\n\t\t#region Destructor\r\n\t\t\r\n\t\t/// <summary>\r\n" +
        "\t\t///\r\n\t\t/// </summary>\r\n\t\t~");

        
        #line default
        #line hidden
        
        #line 96 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 96 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(@"()
		{
		}
		
		#endregion Destructor
		
		#region Set Values
		
		/// <summary>
		/// Set the property values of this instance from the specified <see cref=""CustomDataRow""/>.
		/// </summary>
		public virtual void SetValues(CustomDataRow row)
		{
			foreach (CustomDataColumn column in row)
			{
				switch (column.Name)
				{
				");

        
        #line default
        #line hidden
        
        #line 113 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
 foreach (DBColumn column in tableColumns){
        
        #line default
        #line hidden
        
        #line 113 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\tcase \"");

        
        #line default
        #line hidden
        
        #line 114 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.Name));

        
        #line default
        #line hidden
        
        #line 114 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\" :\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t");

        
        #line default
        #line hidden
        
        #line 116 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.VariableName()));

        
        #line default
        #line hidden
        
        #line 116 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(" = (");

        
        #line default
        #line hidden
        
        #line 116 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.Type()));

        
        #line default
        #line hidden
        
        #line 116 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(")column.Value;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t");

        
        #line default
        #line hidden
        
        #line 119 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
}
        
        #line default
        #line hidden
        
        #line 119 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tIsNew = false;\r\n\t\t}\r\n\t\t\r\n\t\t#endregion Set Values\r\n\t\t\r\n\t\t#reg" +
        "ion Properties\r\n\t\t");

        
        #line default
        #line hidden
        
        #line 129 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
 foreach (DBColumn column in tableColumns)
		{
        
        #line default
        #line hidden
        
        #line 130 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\r\n\t\t#region ");

        
        #line default
        #line hidden
        
        #line 132 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.PropertyName()));

        
        #line default
        #line hidden
        
        #line 132 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\r\n\t\t\r\n\t\tprivate ");

        
        #line default
        #line hidden
        
        #line 134 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.Type()));

        
        #line default
        #line hidden
        
        #line 134 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(" ");

        
        #line default
        #line hidden
        
        #line 134 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.VariableName()));

        
        #line default
        #line hidden
        
        #line 134 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.DefaultValue()));

        
        #line default
        #line hidden
        
        #line 134 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(";\r\n\t\t\r\n\t\t/// <summary>\r\n\t\t/// Column: ");

        
        #line default
        #line hidden
        
        #line 137 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.Name));

        
        #line default
        #line hidden
        
        #line 137 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(";\r\n\t\t/// DBMS data type: ");

        
        #line default
        #line hidden
        
        #line 138 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.DataTypeNameComplete));

        
        #line default
        #line hidden
        
        #line 138 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(";");

        
        #line default
        #line hidden
        
        #line 138 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
 if (column.IsAutoKey){
        
        #line default
        #line hidden
        
        #line 138 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(" Auto key;");

        
        #line default
        #line hidden
        
        #line 138 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
} if (column.IsComputed){
        
        #line default
        #line hidden
        
        #line 138 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(" Computed;");

        
        #line default
        #line hidden
        
        #line 138 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
} if (column.IsNullable){
        
        #line default
        #line hidden
        
        #line 138 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(" Nullable;");

        
        #line default
        #line hidden
        
        #line 138 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
}
        
        #line default
        #line hidden
        
        #line 138 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\r\n\t\t/// </summary>\r\n\t\t");

        
        #line default
        #line hidden
        
        #line 141 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.ColumnDefinition()));

        
        #line default
        #line hidden
        
        #line 141 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\r\n\t\tpublic ");

        
        #line default
        #line hidden
        
        #line 142 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.Type()));

        
        #line default
        #line hidden
        
        #line 142 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(" ");

        
        #line default
        #line hidden
        
        #line 142 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.PropertyName()));

        
        #line default
        #line hidden
        
        #line 142 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\r\n\t\t{\r\n\t\t\tget\r\n\t\t\t{\r\n\t\t\t\treturn ");

        
        #line default
        #line hidden
        
        #line 146 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.VariableName()));

        
        #line default
        #line hidden
        
        #line 146 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(";\r\n\t\t\t}");

        
        #line default
        #line hidden
        
        #line 147 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
 if (!column.IsComputed && !column.IsAutoKey){
        
        #line default
        #line hidden
        
        #line 147 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\r\n\t\t\tset\r\n\t\t\t{");

        
        #line default
        #line hidden
        
        #line 150 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
 if (column.DefaultAction().Trim() != string.Empty){ 
        
        #line default
        #line hidden
        
        #line 150 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\r\n\t\t\t\t");

        
        #line default
        #line hidden
        
        #line 152 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.DefaultAction()));

        
        #line default
        #line hidden
        
        #line 152 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
 } 
        
        #line default
        #line hidden
        
        #line 152 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\r\n\t\t\t\tif (");

        
        #line default
        #line hidden
        
        #line 154 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.VariableName()));

        
        #line default
        #line hidden
        
        #line 154 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(" != value)\r\n\t\t\t\t{\r\n\t\t\t\t\t");

        
        #line default
        #line hidden
        
        #line 156 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.VariableName()));

        
        #line default
        #line hidden
        
        #line 156 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(" = value;\r\n\t\t\t\t\t_IsDirty = true;\r\n\t\t\t\t}\r\n\t\t\t}");

        
        #line default
        #line hidden
        
        #line 159 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
 } else {
        
        #line default
        #line hidden
        
        #line 159 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(@"
			set
			{
				// NOTE: This dummy setter provides a work-around for the following: Read-only properties cannot be exposed by XML Web Services
				// see http://support.microsoft.com/kb/313584
				// Cause: When an object is passed i.e. marshalled to or from a Web service, it must be serialized into an XML stream and then deserialized back into an object.
				// The XML Serializer cannot deserialize the XML back into an object because it cannot load the read-only properties. 
				// Thus the read-only properties are not exposed through the Web Services Description Language (WSDL). 
				// Because the Web service proxy is generated from the WSDL, the proxy also excludes any read-only properties.
			}");

        
        #line default
        #line hidden
        
        #line 169 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
}
        
        #line default
        #line hidden
        
        #line 169 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\r\n\t\t}\r\n\t\t\r\n\t\t#endregion ");

        
        #line default
        #line hidden
        
        #line 173 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.PropertyName()));

        
        #line default
        #line hidden
        
        #line 173 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\r\n\t\t");

        
        #line default
        #line hidden
        
        #line 174 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
}
        
        #line default
        #line hidden
        
        #line 174 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\t\r\n\t\t#endregion Properties\r\n\r\n\t\t#region From Array serialization\r\n\t\t\r\n\t\t/// <summ" +
        "ary>\r\n\t\t/// Deserializes the byte array and returns an instance of <see cref=\"");

        
        #line default
        #line hidden
        
        #line 180 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 180 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\"/>.\r\n\t\t/// </summary>\r\n\t\t/// <returns>If the byte array can be deserialized and " +
        "cast to an instance of <see cref=\"");

        
        #line default
        #line hidden
        
        #line 182 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 182 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\"/>, \r\n\t\t/// returns an instance of <see cref=\"");

        
        #line default
        #line hidden
        
        #line 183 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 183 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\"/>; otherwise returns null.</returns>\r\n\t\tpublic static new ");

        
        #line default
        #line hidden
        
        #line 184 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 184 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(" FromArray(byte[] byteArray)\r\n\t\t{\r\n\t\t\t");

        
        #line default
        #line hidden
        
        #line 186 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 186 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(" o = null;\r\n\t\t\t\r\n\t\t\ttry\r\n\t\t\t{\r\n\t\t\t\to = (");

        
        #line default
        #line hidden
        
        #line 190 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 190 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(@") CustomObjectBase.FromArray(byteArray);
			}
			catch (Exception e)
			{
				throw e;
			}

			return o;
		}
		
		#endregion From Array serialization

		#region CompareTo
		
		/// <summary>
		/// Compares this instance with a specified object. Throws an ArgumentException if the specified object is not of type <see cref=""");

        
        #line default
        #line hidden
        
        #line 205 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 205 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\"/>.\r\n\t\t/// </summary>\r\n\t\t/// <param name=\"obj\">An <see cref=\"");

        
        #line default
        #line hidden
        
        #line 207 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 207 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\"/> object to compare with this instance.</param>\r\n\t\t/// <returns>0 if the specif" +
        "ied object equals this instance; -1 if the specified object does not equal this " +
        "instance.</returns>\r\n\t\tpublic virtual int CompareTo(Object obj)\r\n\t\t{\r\n\t\t\tif (obj" +
        " is ");

        
        #line default
        #line hidden
        
        #line 211 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 211 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(")\r\n\t\t\t{\r\n\t\t\t\t");

        
        #line default
        #line hidden
        
        #line 213 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 213 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(" o = (");

        
        #line default
        #line hidden
        
        #line 213 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 213 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(") obj;\r\n\t\t\t\t\r\n\t\t\t\tif (");

        
        #line default
        #line hidden
        
        #line 215 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
 string conjunction = string.Empty; 
				if (tableColumns.Length > 0)
				{
					conjunction = " &&";
				}
        
        #line default
        #line hidden
        
        #line 219 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\r\n\t\t\t\t\to.IsNew == IsNew &&\r\n\t\t\t\t\to.IsDeleted == IsDeleted");

        
        #line default
        #line hidden
        
        #line 222 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(conjunction));

        
        #line default
        #line hidden
        
        #line 222 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
 int y = 0;
				foreach (DBColumn column in tableColumns)
				{
					if (y < tableColumns.Length -1)
					{
						conjunction = "&&";
					}
					else
					{
						conjunction = "";
					}
					y++;
					string compareTo = string.Empty;
					
					if (column.LanguageType == "string")
					{
						compareTo = string.Format("GetComparisonString(o.{0}) == GetComparisonString({0}) {1}", column.PropertyName(), conjunction);
					}
					else
					{
						compareTo = string.Format("o.{0} == {0} {1}", column.PropertyName(), conjunction);
					}
					
        
        #line default
        #line hidden
        
        #line 244 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\r\n\t\t\t\t\t");

        
        #line default
        #line hidden
        
        #line 246 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(compareTo));

        
        #line default
        #line hidden
        
        #line 246 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
}
        
        #line default
        #line hidden
        
        #line 246 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\r\n\t\t\t\t)\r\n\t\t\t\t{\r\n\t\t\t\t\to = null;\r\n\t\t\t\t\treturn 0; // true\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t" +
        "\t\t\t\to = null;\r\n\t\t\t\t\treturn -1; // false\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthrow n" +
        "ew ArgumentException(\"Argument is not of type ");

        
        #line default
        #line hidden
        
        #line 261 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 261 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\");\r\n\t\t\t}\r\n\t\t}\r\n \t\t\r\n\t\t#endregion CompareTo\r\n\t\t\r\n\t\t#region Operators\r\n\t\t\r\n\t\t/// <" +
        "summary>\r\n\t\t/// Equality operator (==) returns true if the values of its operand" +
        "s are equal, false otherwise.\r\n\t\t/// </summary>\r\n\t\t/// <param name=\"a\">The first" +
        " <see cref=\"");

        
        #line default
        #line hidden
        
        #line 272 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 272 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\"/> object to compare.</param>\r\n\t\t/// <param name=\"b\">The second <see cref=\"");

        
        #line default
        #line hidden
        
        #line 273 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 273 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\"/> object to compare.</param>\r\n\t\t/// <returns>true if values of operands are equ" +
        "al, false otherwise.</returns>\r\n\t\tpublic static bool operator == (");

        
        #line default
        #line hidden
        
        #line 275 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 275 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(" a, ");

        
        #line default
        #line hidden
        
        #line 275 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 275 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(@" b)
		{
			if (((Object) a) == null || ((Object) b) == null)
			{
				if (((Object) a) == null && ((Object) b) == null)
				{
					return true;
				}
			}
			else
			{
				int r = a.CompareTo(b);
				
				if (r == 0)
				{
					return true;
				}
				else
				{
					return false;
				}
			}
			
			return false;
		}
		
		/// <summary>
		/// Inequality operator (!=) returns false if its operands are equal, true otherwise.
		/// </summary>
		/// <param name=""a"">The first <see cref=""");

        
        #line default
        #line hidden
        
        #line 304 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 304 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\"/> object to compare.</param>\r\n\t\t/// <param name=\"b\">The second <see cref=\"");

        
        #line default
        #line hidden
        
        #line 305 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 305 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\"/> object to compare.</param>\r\n\t\t/// <returns>false if values of operands are eq" +
        "ual, false otherwise.</returns>\r\n\t\tpublic static bool operator !=(");

        
        #line default
        #line hidden
        
        #line 307 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 307 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(" a, ");

        
        #line default
        #line hidden
        
        #line 307 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 307 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(" b)\r\n\t\t{\r\n\t\t\treturn !(a == b);\r\n\t\t}\r\n\t\t\r\n\t\t/// <summary>\r\n\t\t/// Returns true the " +
        "specified object is equal to this object instance, false otherwise.\r\n\t\t/// </sum" +
        "mary>\r\n\t\t/// <param name=\"obj\">The <see cref=\"");

        
        #line default
        #line hidden
        
        #line 315 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 315 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\"/> object to compare with the current <see cref=\"");

        
        #line default
        #line hidden
        
        #line 315 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 315 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\"/>.</param>\r\n\t\t/// <returns>true if specified object is equal to the instance of" +
        " this object, false otherwise.</returns>\r\n\t\tpublic override bool Equals(Object o" +
        "bj)\r\n\t\t{\r\n\t\t\tif (!(obj is ");

        
        #line default
        #line hidden
        
        #line 319 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 319 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("))\r\n\t\t\t{\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\treturn this == (");

        
        #line default
        #line hidden
        
        #line 324 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 324 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(@") obj;
		}
	
        /// <summary>
        /// Returns the hash code for this instance.
        /// </summary>
        /// <returns>Hash code for this instance as an integer.</returns>
		public override int GetHashCode()
		{
			return base.GetHashCode();
		}
		
		#endregion Operators
		
		#region SortColumn
		
		/// <summary>
		/// Use when defining sort columns for a collection sort request.
		/// For example where list is a instance of <see cref=""CustomGenericList"">, 
		/// list.Sort(SortOrder.Ascending, ");

        
        #line default
        #line hidden
        
        #line 343 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(className));

        
        #line default
        #line hidden
        
        #line 343 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(".SortColumn.");

        
        #line default
        #line hidden
        
        #line 343 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(tableColumns[0].Alias));

        
        #line default
        #line hidden
        
        #line 343 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(");\r\n\t\t/// </summary>\r\n\t\t[Serializable]\r\n\t\tpublic sealed class SortColumn\r\n\t\t{");

        
        #line default
        #line hidden
        
        #line 347 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
foreach (DBColumn column in tableColumns)
		{
        
        #line default
        #line hidden
        
        #line 348 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\t\r\n\t\t\tpublic const string ");

        
        #line default
        #line hidden
        
        #line 349 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.PropertyName()));

        
        #line default
        #line hidden
        
        #line 349 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(" = \"");

        
        #line default
        #line hidden
        
        #line 349 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(column.PropertyName()));

        
        #line default
        #line hidden
        
        #line 349 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\";");

        
        #line default
        #line hidden
        
        #line 349 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
}
        
        #line default
        #line hidden
        
        #line 349 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
this.Write("\r\n\t\t}\r\n\t\t\t\t\r\n\t\t#endregion SortColumn\r\n\t}\r\n}\r\n// end of source generation\r\n");

        
        #line default
        #line hidden
        
        #line 357 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\AbstractObjectClass.tt"
	
}
Пример #13
0
	private void renderSqlUpdate(DBColumn[] columns, string schemaName, string objectName, string procedureName)
	{
		DateTime generated = DateTime.Now;
		StringBuilder entrySb = new StringBuilder();
		StringBuilder setSb = new StringBuilder();
		StringBuilder whereSb = new StringBuilder();
		StringBuilder ccSelectSb = new StringBuilder();
		StringBuilder ccWhereSb = new StringBuilder();
		StringBuilder returnSelectSb = new StringBuilder();
		StringBuilder returnWhereSb = new StringBuilder();
		
		int v = 0; // used in conjunction with returnSelectSb
		int w = 0; // used in conjunction with ccSelectSb, ccWhereSb
		int x = 0; // used in conjunction with entrySb
		int y = 0; // used in conjunction with setSb
		int z = 0; // used in conjunction with whereSb
		
		bool optimisticConcurrency = false;
		
		foreach (DBColumn column in columns)
		{
			if (!DataAccess.isModifiedDate(column) && 
				!DataAccess.isCreatedDate(column) && 
				!DataAccess.isCreationUserId(column) )
			{
				// entry values; Note does not include the recognized special columns
				if (x > 0) entrySb.AppendFormat(",\r\n");
				entrySb.AppendFormat("@{0} {1}", column.Name, column.DataTypeNameComplete.ToUpper());
				x++;
			}
			
			// set values; Note does not include computed columns, auto key columns, recognized special columns handled discreetly
			if (!column.IsComputed && !column.IsAutoKey && !DataAccess.isCreatedDate(column) && !DataAccess.isCreationUserId(column))
			{
				if (y > 0) setSb.AppendFormat(",\r\n");
				
				if (DataAccess.isModifiedDate(column))
				{
					setSb.AppendFormat("\t[{0}] = getdate()", column.Name);
				}
				else
				{
					setSb.AppendFormat("\t[{0}] = @{0}", column.Name);
				}
				
				y++;
			}
			
			if (column.IsInPrimaryKey || column.IsComputed)
			{
				if (z > 0) whereSb.AppendFormat(" AND\r\n");
				whereSb.AppendFormat("\t[{0}] = @{0}", column.Name);
				z++;
			}
			
			if (column.IsInPrimaryKey)
			{
				if (w > 0)
				{
					ccSelectSb.AppendFormat(", ");
					ccWhereSb.AppendFormat(" AND ");
					returnWhereSb.AppendFormat(" AND \r\n");
				}
				
				ccSelectSb.AppendFormat("[{0}]", column.Name);
				ccWhereSb.AppendFormat("[{0}] = @{0}", column.Name);
				returnWhereSb.AppendFormat("\t\t[{0}] = @{0}", column.Name);
				
				w++;
			}
			
			if (column.IsComputed && column.DataTypeName == "timestamp") optimisticConcurrency = true;
			if (v > 0) returnSelectSb.AppendFormat(",\r\n");
			
			returnSelectSb.AppendFormat("\t\t[{0}]", column.Name);
			
			v++;
		}
		
		string entryString = entrySb.ToString();
		string setString = setSb.ToString();
		string whereString = whereSb.ToString();
		string ccString = string.Format("SELECT {0} FROM {1} WHERE {2}", ccSelectSb.ToString(), objectName, ccWhereSb.ToString());
		string returnSelectString = returnSelectSb.ToString();
		string returnWhereString = returnWhereSb.ToString();
		
		entrySb = null;
		setSb = null;
		whereSb = null;
		ccSelectSb = null;
		ccWhereSb = null;
		returnSelectSb = null;
		returnWhereSb = null;

        
        #line default
        #line hidden
        
        #line 106 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("IF EXISTS(SELECT * FROM dbo.sysobjects WHERE id = object_id(N\'[");

        
        #line default
        #line hidden
        
        #line 107 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 107 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("].[");

        
        #line default
        #line hidden
        
        #line 107 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(procedureName));

        
        #line default
        #line hidden
        
        #line 107 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("]\') AND OBJECTPROPERTY(id, N\'IsProcedure\') = 1)\r\nDROP PROCEDURE [");

        
        #line default
        #line hidden
        
        #line 108 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 108 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("].[");

        
        #line default
        #line hidden
        
        #line 108 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(procedureName));

        
        #line default
        #line hidden
        
        #line 108 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("]\r\nGO\r\n\r\nSET QUOTED_IDENTIFIER ON\r\nGO\r\nSET ANSI_NULLS ON\r\nGO\r\n\r\n-- Update Procedu" +
        "re for ");

        
        #line default
        #line hidden
        
        #line 116 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 116 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(".");

        
        #line default
        #line hidden
        
        #line 116 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(objectName));

        
        #line default
        #line hidden
        
        #line 116 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("\r\n-- Do not modify the contents of this procedure.\r\n-- Generated ");

        
        #line default
        #line hidden
        
        #line 118 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(generated.ToString()));

        
        #line default
        #line hidden
        
        #line 118 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("\r\n\r\nCREATE PROCEDURE ");

        
        #line default
        #line hidden
        
        #line 120 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 120 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(".");

        
        #line default
        #line hidden
        
        #line 120 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(procedureName));

        
        #line default
        #line hidden
        
        #line 120 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("\r\n\r\n");

        
        #line default
        #line hidden
        
        #line 122 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(entryString));

        
        #line default
        #line hidden
        
        #line 122 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("\r\n\r\nAS \r\n\r\nSET NOCOUNT ON\r\n\r\nUPDATE [");

        
        #line default
        #line hidden
        
        #line 128 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 128 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("].[");

        
        #line default
        #line hidden
        
        #line 128 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(objectName));

        
        #line default
        #line hidden
        
        #line 128 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("]\r\nSET\r\n");

        
        #line default
        #line hidden
        
        #line 130 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(setString));

        
        #line default
        #line hidden
        
        #line 130 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("\r\nWHERE\r\n");

        
        #line default
        #line hidden
        
        #line 132 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(whereString));

        
        #line default
        #line hidden
        
        #line 132 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("\r\n");

        
        #line default
        #line hidden
        
        #line 133 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
		if (optimisticConcurrency)
		{

        
        #line default
        #line hidden
        
        #line 135 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(@"------------------------------------------------------------------------------------------------------------------------------------------------------"",
-- Note about OPTIMISTIC CONCURRENCY

-- The SQL Server timestamp (alias rowversion) field is modified everytime a change is made to the row containing it.
-- Verification that the timestamp contains the same original value is assurance that none of the fields have been changed prior to this update request.

-- If the number of rows affected equals zero, then the update failed, else the update request was successful.

------------------------------------------------------------------------------------------------------------------------------------------------------

IF @@ROWCOUNT = 0 -- zero records affected
BEGIN
	IF EXISTS(");

        
        #line default
        #line hidden
        
        #line 148 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(ccString));

        
        #line default
        #line hidden
        
        #line 148 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(") BEGIN\r\n\t\t-- raiserror will throw a SqlException\r\n\t\tRAISERROR(\'A optimistic conc" +
        "urrency error occurred in procedure ");

        
        #line default
        #line hidden
        
        #line 150 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 150 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(".");

        
        #line default
        #line hidden
        
        #line 150 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(procedureName));

        
        #line default
        #line hidden
        
        #line 150 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(@". No information was updated as a result of this request because some of the information had been changed prior to this update request.', 16, 1)
		RETURN 8 -- concurrency failure; the record exists, but the concurrency (timestamp) field had changed prior to this request
	END
	ELSE BEGIN
		-- raiserror will throw a SqlException
		RAISERROR('An error occurred in procedure ");

        
        #line default
        #line hidden
        
        #line 155 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 155 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(".");

        
        #line default
        #line hidden
        
        #line 155 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(procedureName));

        
        #line default
        #line hidden
        
        #line 155 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(". No information was updated as a result of this request because the record could" +
        " not be accessed based upon the key information provided.\', 16, 1)\r\n\t\tRETURN 9 -" +
        "- record does not exist based upon the primary key(s)\r\n\tEND\r\nEND\r\nELSE BEGIN\r\n\tS" +
        "ELECT\r\n");

        
        #line default
        #line hidden
        
        #line 161 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(returnSelectString));

        
        #line default
        #line hidden
        
        #line 161 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("\r\n\tFROM [");

        
        #line default
        #line hidden
        
        #line 162 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 162 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("].[");

        
        #line default
        #line hidden
        
        #line 162 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(objectName));

        
        #line default
        #line hidden
        
        #line 162 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("]\r\n\tWHERE\r\n");

        
        #line default
        #line hidden
        
        #line 164 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(returnWhereString));

        
        #line default
        #line hidden
        
        #line 164 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("\r\n\t\r\n\tRETURN -- update successful\r\nEND\r\n");

        
        #line default
        #line hidden
        
        #line 168 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
		}
		else
		{

        
        #line default
        #line hidden
        
        #line 171 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("\t\t\r\nIF @@ERROR <> 0\r\nBEGIN\r\n\t-- raiserror will throw a SqlException\r\n\tRAISERROR(\'" +
        "An error occurred in procedure ");

        
        #line default
        #line hidden
        
        #line 175 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 175 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(".");

        
        #line default
        #line hidden
        
        #line 175 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(procedureName));

        
        #line default
        #line hidden
        
        #line 175 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(". No information was updated as a result of this request.\', 16, 1)\r\n\tRETURN 9 -- " +
        "error occurred\r\nEND\r\nELSE BEGIN\r\n\tSELECT\r\n");

        
        #line default
        #line hidden
        
        #line 180 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(returnSelectString));

        
        #line default
        #line hidden
        
        #line 180 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("\r\n\tFROM [");

        
        #line default
        #line hidden
        
        #line 181 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 181 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("].[");

        
        #line default
        #line hidden
        
        #line 181 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(objectName));

        
        #line default
        #line hidden
        
        #line 181 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("]\r\n\tWHERE\r\n");

        
        #line default
        #line hidden
        
        #line 183 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(returnWhereString));

        
        #line default
        #line hidden
        
        #line 183 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("\r\n\t\r\n\tRETURN -- update successful\r\nEND\r\n");

        
        #line default
        #line hidden
        
        #line 187 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
		}

        
        #line default
        #line hidden
        
        #line 188 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
this.Write("GO\r\n \r\nSET QUOTED_IDENTIFIER OFF\r\nGO\r\nSET ANSI_NULLS ON\r\nGO\r\n");

        
        #line default
        #line hidden
        
        #line 195 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\UpdateProc.tt"
	
	}
Пример #14
0
	private void renderSqlInsert(DBColumn[] columns, string schemaName, string objectName, string procedureName)
	{
		DateTime generated = DateTime.Now;
		StringBuilder entrySb = new StringBuilder();
		StringBuilder columnSb = new StringBuilder();
		StringBuilder valueSb = new StringBuilder();
		StringBuilder returnSelectSb = new StringBuilder();
		StringBuilder returnWhereSb = new StringBuilder();
		
		string returnAction = string.Empty;

		int v = 0;
		int w = 0;
		int x = 0;
		int y = 0;
		
		foreach (DBColumn column in columns)
		{
			if (!column.IsComputed)
			{
				// special columns recognized by name and data type only
				if (!DataAccess.isModifiedDate(column) &&
					!DataAccess.isCreatedDate(column) )
				{
					if (x > 0) entrySb.AppendFormat(",\r\n");
					entrySb.AppendFormat("@{0} {1}", column.Name, column.DataTypeNameComplete.ToUpper());
		
					if (column.IsAutoKey)
					{
						entrySb.AppendFormat(" OUTPUT");
					}
					else if (column.IsNullable)
					{
						entrySb.AppendFormat(" = null");
					}
					
					x++;
				}
			}
			
			if (!column.IsComputed && !column.IsAutoKey)
			{
				if (y > 0)
				{
					columnSb.AppendFormat(",\r\n");
					valueSb.AppendFormat(",\r\n");
				}
				
				columnSb.AppendFormat("\t[{0}]", column.Name);
				
				// special columns recognized by name and data type only
				if (DataAccess.isModifiedDate(column))
				{
					valueSb.AppendFormat("\tgetdate()"); // default function
				}
				else if (DataAccess.isCreatedDate(column))
				{
					valueSb.AppendFormat("\tgetdate()"); // default function
				}
				else
				{
					valueSb.AppendFormat("\t@{0}", column.Name);
				}
				
				y++;
			}
			
			if (column.IsAutoKey) returnAction = string.Format("\r\nSET @{0} = Scope_Identity()\r\n", column.Name);
			if (v > 0) returnSelectSb.AppendFormat(",\r\n");
			returnSelectSb.AppendFormat("\t\t[{0}]", column.Name);
			v++;

			if (column.IsInPrimaryKey)
			{
				if (w > 0) returnWhereSb.AppendFormat(" AND\r\n");
				returnWhereSb.AppendFormat("\t\t[{0}] = @{0}", column.Name);
				w++;
			}
		}
		
		string entryString = entrySb.ToString();
		string columnString = columnSb.ToString();
		string valueString = valueSb.ToString();
		string returnSelectString = returnSelectSb.ToString();
		string returnWhereString = returnWhereSb.ToString();
		
		entrySb = null;
		columnSb = null;
		valueSb = null;
		returnSelectSb = null;
		returnWhereSb = null;

        
        #line default
        #line hidden
        
        #line 104 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write("IF EXISTS(SELECT * FROM dbo.sysobjects WHERE id = object_id(N\'[");

        
        #line default
        #line hidden
        
        #line 105 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 105 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write("].[");

        
        #line default
        #line hidden
        
        #line 105 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(procedureName));

        
        #line default
        #line hidden
        
        #line 105 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write("]\') AND OBJECTPROPERTY(id, N\'IsProcedure\') = 1)\r\nDROP PROCEDURE [dbo].[");

        
        #line default
        #line hidden
        
        #line 106 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(procedureName));

        
        #line default
        #line hidden
        
        #line 106 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write("]\r\nGO\r\n\r\nSET QUOTED_IDENTIFIER ON\r\nGO\r\nSET ANSI_NULLS ON\r\nGO\r\n\r\n-- Insert Procedu" +
        "re for ");

        
        #line default
        #line hidden
        
        #line 114 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 114 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(".");

        
        #line default
        #line hidden
        
        #line 114 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(objectName));

        
        #line default
        #line hidden
        
        #line 114 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write("\r\n-- Do not modify the contents of this procedure.\r\n-- Generated ");

        
        #line default
        #line hidden
        
        #line 116 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(generated.ToString()));

        
        #line default
        #line hidden
        
        #line 116 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write("\r\n\r\nCREATE PROCEDURE ");

        
        #line default
        #line hidden
        
        #line 118 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 118 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(".");

        
        #line default
        #line hidden
        
        #line 118 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(procedureName));

        
        #line default
        #line hidden
        
        #line 118 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write("\r\n\r\n");

        
        #line default
        #line hidden
        
        #line 120 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(entryString));

        
        #line default
        #line hidden
        
        #line 120 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write("\r\n\r\nAS \r\n\r\nSET NOCOUNT ON\r\n\r\nINSERT INTO [");

        
        #line default
        #line hidden
        
        #line 126 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 126 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write("].[");

        
        #line default
        #line hidden
        
        #line 126 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(objectName));

        
        #line default
        #line hidden
        
        #line 126 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write("]\r\n( ");

        
        #line default
        #line hidden
        
        #line 127 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(columnString));

        
        #line default
        #line hidden
        
        #line 127 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(" )\r\nVALUES\r\n( ");

        
        #line default
        #line hidden
        
        #line 129 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(valueString));

        
        #line default
        #line hidden
        
        #line 129 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(" )\r\n");

        
        #line default
        #line hidden
        
        #line 130 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(returnAction));

        
        #line default
        #line hidden
        
        #line 130 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write("\r\nIF @@ERROR <> 0\r\nBEGIN\r\n\t-- raiserror will throw a SqlException\r\n\tRAISERROR(\'An" +
        " error occurred in procedure ");

        
        #line default
        #line hidden
        
        #line 134 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 134 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(".");

        
        #line default
        #line hidden
        
        #line 134 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(procedureName));

        
        #line default
        #line hidden
        
        #line 134 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(". No information was inserted as a result of this request.\', 16, 1)\r\n\tRETURN 9 --" +
        " error occurred\r\nEND\r\nELSE BEGIN\r\n\tSELECT\r\n");

        
        #line default
        #line hidden
        
        #line 139 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(returnSelectString));

        
        #line default
        #line hidden
        
        #line 139 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write("\t\r\n\tFROM [");

        
        #line default
        #line hidden
        
        #line 140 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(schemaName));

        
        #line default
        #line hidden
        
        #line 140 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write("].[");

        
        #line default
        #line hidden
        
        #line 140 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(objectName));

        
        #line default
        #line hidden
        
        #line 140 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write("]\r\n\tWHERE\r\n");

        
        #line default
        #line hidden
        
        #line 142 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(returnWhereString));

        
        #line default
        #line hidden
        
        #line 142 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
this.Write("\r\n\t\r\n\tRETURN -- insert successful\r\nEND\r\nGO\r\n \r\nSET QUOTED_IDENTIFIER OFF\r\nGO\r\nSET" +
        " ANSI_NULLS ON\r\nGO\r\n");

        
        #line default
        #line hidden
        
        #line 152 "C:\Users\mikel\Dropbox\MWLShare\DALCodeGen\DALCodeGen\sql\InsertProc.tt"
	
	}
Пример #15
0
 public static bool isAuthorityId(DBColumn column)
 {
     return(column.Name.ToLower() == "authorityid" && column.DataTypeName.ToLower() == "int");
 }
Пример #16
0
 private bool IsColumnValidForInsert(DBColumn column)
 {
     bool isValid = false;
     if (!DataAccess.isModifiedDate(column) && !DataAccess.isCreatedDate(column) && !DataAccess.isAuthorityId(column))
     {
         isValid = !column.IsAutoKey && !column.IsComputed;
     }
     return isValid;
 }
Пример #17
0
 public static bool isCreationUserId(DBColumn column)
 {
     return(column.Name.ToLower() == "creationuserid" && column.DataTypeName.ToLower() == "int");
 }
Пример #18
0
 private bool IsColumnValidForUpdate(DBColumn column)
 {
     return(!DataAccess.isModifiedDate(column) && !DataAccess.isCreatedDate(column) &&
            !DataAccess.isAuthorityId(column) && !DataAccess.isCreationUserId(column));
 }