public override void GenerateSelectSp(DataEntityModel de, TextWriter sw) { Oracle8SpGenerator.SelectSp(de, sw); }
// Methods public TableOperation(TableOperationType type, DataEntityModel entity) { m_Type = type; m_Table = entity; base.m_DataLayer = entity.Parent; }
public BusinessDocModel NewDocument(string docName, DataEntityModel de) { BusinessDocModel dm = new BusinessDocModel(docName, de); Add(dm); dm.Parent = this; return dm; }
public static void SelectDispsetAllSp(DataEntityModel tableInfo, TextWriter sw) { string str = GetSpName(tableInfo.Parent, tableInfo, TableOperationType.SelectDispsetAll); TraceInfoEvent.Raise(string.Format("Generating SP '{0}'.", str)); HeadingComment(sw, str, string.Format("Retrieves all {0} record with display set fields.", tableInfo.MappingName)); ProcHead(sw, str); sw.WriteLine("as"); sw.WriteLine(" select"); FieldList(sw, " [{0}]", tableInfo.DispFields); //sw.WriteLine(string.Format(" from [{0}] with (nolock)", tableInfo.MappingName)); sw.WriteLine(string.Format(" from [{0}] with (nolock)", tableInfo.MappingName)); sw.WriteLine(); sw.WriteLine(" return @@rowcount"); sw.WriteLine("GO"); sw.WriteLine(); }
public static void UpdateSp(DataEntityModel tableInfo, TextWriter sw) { string str = GetSpName(tableInfo.Parent, tableInfo, TableOperationType.Update); TraceInfoEvent.Raise(string.Format("Generating SP '{0}'.", str)); HeadingComment(sw, str, string.Format("Updates a {0} record.", tableInfo.MappingName)); ProcHead(sw, str); FieldList(sw, " @{0} {1}", tableInfo.UpdateParamFields); sw.WriteLine("as"); sw.WriteLine(string.Format(" update [{0}]", tableInfo.MappingName)); sw.WriteLine(" set"); FieldList(sw, " {0} = @{0}", tableInfo.UpdateSetFields); sw.WriteLine(" where"); ConditionList(sw, " {0} = @{0}", tableInfo.PKFields); sw.WriteLine(); sw.WriteLine(" return @@rowcount"); sw.WriteLine("GO"); sw.WriteLine(); }
internal void ScriptTableProp(DataEntityModel table, string propName, string propValue, TextWriter sw) { sw.WriteLine(string.Format("exec sp_addextendedproperty @name='{0}',", SqlHelper.SqlString(propName))); sw.WriteLine(string.Format(" @value='{0}',", SqlHelper.SqlString(propValue))); sw.WriteLine(" @level0type='user', @level0name='dbo',"); sw.WriteLine(string.Format(" @level1type='table', @level1name='{0}'", table.Name)); sw.WriteLine("GO"); sw.WriteLine(); }
public static string GetSpName(DataAccessModel daLayer, DataEntityModel de, TableOperationType opType) { return string.Format("{0}{1}{2}", daLayer.Prefix, de.MappingName, opType); }
public static string GetSpName(DataAccessModel daLayer, DataEntityModel de, string opType) { string str = CapitalizeFirstLetter(daLayer.NormalizeTableName(de.MappingName)); return string.Format("{0}{1}{2}", daLayer.Prefix, str, opType); }
public static void InsertSp(DataEntityModel tableInfo, TextWriter sw) { string str = tableInfo.Parent.InsertSpName(tableInfo); TraceInfoEvent.Raise(string.Format("Generating SP '{0}'.", str)); HeadingComment(sw, str, string.Format("Inserts a new {0} record.", tableInfo.Name)); ProcHead(sw, str, tableInfo.InsertParamFields, false, false); sw.WriteLine("AS"); sw.WriteLine("BEGIN"); sw.WriteLine(string.Format(" INSERT INTO {0}", tableInfo.Name)); sw.WriteLine(" ("); string str2 = string.Empty; string str3 = string.Empty; foreach (DataFieldModel model in tableInfo.Fields) { if (model.IsIdentity) { str2 = string.Format(" {0},", model.Name); str3 = string.Format(" sq{0}.NEXTVAL,", tableInfo.Name); } } sw.WriteLine("{0}", str2); FieldList(sw, " {0}", tableInfo.InsertParamFields); sw.WriteLine(" )"); sw.WriteLine(" VALUES"); sw.WriteLine(" ("); sw.WriteLine("{0}", str3); FieldList(sw, " i{0}", tableInfo.InsertParamFields); sw.WriteLine(" );"); sw.WriteLine(string.Format("END {0};", str)); sw.WriteLine(); }
internal void ScriptTableComment(DataEntityModel table, string propValue, TextWriter sw) { if (propValue != string.Empty) { sw.WriteLine(string.Format("COMMENT ON TABLE {0} IS", table.Name)); sw.WriteLine(string.Format(" '{0}';", SqlHelper.SqlString(propValue))); sw.WriteLine(); } }
public static void DeleteSp(DataEntityModel tableInfo, TextWriter sw) { string str = tableInfo.Parent.DeleteSpName(tableInfo); TraceInfoEvent.Raise(string.Format("Generating SP '{0}'.", str)); HeadingComment(sw, str, string.Format("Deletes the specified {0} record.", tableInfo.Name)); ProcHead(sw, str, tableInfo.PKFields, false, false); sw.WriteLine("AS"); sw.WriteLine("BEGIN"); sw.WriteLine(string.Format(" DELETE FROM {0}", tableInfo.Name)); sw.WriteLine(" WHERE"); ConditionList(sw, " {0} = i{0}", tableInfo.PKFields); sw.WriteLine(string.Format("END {0};", str)); sw.WriteLine(); }
public override string UpdateSpName(DataEntityModel de) { return Oracle8SpGenerator.GetSpName(de.Parent, de, "Update"); }
public override string SelectSpName(DataEntityModel de) { return Oracle8SpGenerator.GetSpName(de.Parent, de, "Select"); }
public override void GenerateUpdateHeader(DataEntityModel de, TextWriter sw) { string str = de.Parent.UpdateSpName(de); sw.Write(string.Format("PROCEDURE {0}(", str)); Oracle8SpGenerator.PackageHeaderFieldList(sw, "i{0} IN {1}", de.UpdateParamFields); sw.Write(", returnValue OUT NUMBER"); sw.WriteLine(");"); }
public override string SelectDispsetAllSpName(DataEntityModel de) { return Sql2000SpGenerator.GetSpName(de.Parent, de, TableOperationType.SelectDispsetAll); }
public static void SelectDispsetAllSp(DataEntityModel tableInfo, TextWriter sw) { string str = tableInfo.Parent.SelectDispsetAllSpName(tableInfo); TraceInfoEvent.Raise(string.Format("Generating SP '{0}'.", str)); HeadingComment(sw, str, string.Format("Retrieves all {0} record with display set fields.", tableInfo.Name)); ProcHead(sw, str, null, true, false); sw.WriteLine("AS"); sw.WriteLine("BEGIN"); sw.WriteLine(" OPEN oresult FOR"); sw.WriteLine(" SELECT"); FieldList(sw, " {0}", tableInfo.DispFields); sw.WriteLine(string.Format(" FROM {0};", tableInfo.Name)); sw.WriteLine(); sw.WriteLine(string.Format("END {0};", str)); sw.WriteLine(); }
public override string UpdateSpName(DataEntityModel de) { return Sql2000SpGenerator.GetSpName(de.Parent, de, TableOperationType.Update); }
public static void SelectSp(DataEntityModel tableInfo, TextWriter sw) { string str = tableInfo.Parent.SelectSpName(tableInfo); TraceInfoEvent.Raise(string.Format("Generating SP '{0}'.", str)); HeadingComment(sw, str, string.Format("Selects the specified {0} record.", tableInfo.Name)); ProcHead(sw, str, tableInfo.PKFields, true, false); sw.WriteLine("AS"); sw.WriteLine("BEGIN"); sw.WriteLine(" OPEN oresult FOR"); sw.WriteLine(" SELECT"); FieldList(sw, " {0}", tableInfo.Fields); sw.WriteLine(string.Format(" FROM {0}", tableInfo.Name)); sw.WriteLine(" WHERE"); ConditionList(sw, " {0} = i{0}", tableInfo.PKFields); sw.WriteLine(); sw.WriteLine(string.Format("END {0};", str)); sw.WriteLine(); }
public static void DeleteSp(DataEntityModel tableInfo, TextWriter sw) { string str = GetSpName(tableInfo.Parent, tableInfo, TableOperationType.Delete); TraceInfoEvent.Raise(string.Format("Generating SP '{0}'.", str)); HeadingComment(sw, str, string.Format("Deletes the specified {0} record.", tableInfo.MappingName)); ProcHead(sw, str); FieldList(sw, " @{0} {1}", tableInfo.PKFields); sw.WriteLine("as"); sw.WriteLine(string.Format(" delete from [{0}]", tableInfo.MappingName)); sw.WriteLine(" where"); ConditionList(sw, " {0} = @{0}", tableInfo.PKFields); sw.WriteLine("GO"); sw.WriteLine(); }
public static void UpdateSp(DataEntityModel tableInfo, TextWriter sw) { string str = tableInfo.Parent.UpdateSpName(tableInfo); TraceInfoEvent.Raise(string.Format("Generating SP '{0}'.", str)); HeadingComment(sw, str, string.Format("Updates a {0} record.", tableInfo.Name)); ProcHead(sw, str, tableInfo.UpdateParamFields, false, true); sw.WriteLine("AS"); sw.WriteLine("BEGIN"); sw.WriteLine(string.Format(" UPDATE {0}", tableInfo.Name)); sw.WriteLine(" SET"); FieldList(sw, " {0} = i{0}", tableInfo.UpdateSetFields); sw.WriteLine(" WHERE"); ConditionList(sw, " {0} = i{0}", tableInfo.PKFields); sw.WriteLine(); sw.WriteLine(" returnValue := SQL%ROWCOUNT;"); sw.WriteLine(string.Format("END {0};", str)); sw.WriteLine(); }
public static void InsertSp(DataEntityModel tableInfo, TextWriter sw) { string str = GetSpName(tableInfo.Parent, tableInfo, TableOperationType.Insert); TraceInfoEvent.Raise(string.Format("Generating SP '{0}'.", str)); HeadingComment(sw, str, string.Format("Inserts a new {0} record.", tableInfo.MappingName)); ProcHead(sw, str); FieldList(sw, " @{0} {1}", tableInfo.InsertParamFields); sw.WriteLine("as"); sw.WriteLine(string.Format(" insert into [{0}]", tableInfo.MappingName)); sw.WriteLine(" ("); FieldList(sw, " [{0}]", tableInfo.InsertParamFields); sw.WriteLine(" )"); sw.WriteLine(" values"); sw.WriteLine(" ("); FieldList(sw, " @{0}", tableInfo.InsertParamFields); sw.WriteLine(" )"); sw.WriteLine("GO"); sw.WriteLine(); }
public override void CreationScript(DataEntityModel table, TextWriter sw) { sw.WriteLine("------------------------------------------------------------------"); sw.WriteLine(string.Format("-- Create the [{0}] table", table.Name)); sw.WriteLine("------------------------------------------------------------------"); sw.WriteLine(string.Format("create table [dbo].[{0}]", table.Name)); sw.WriteLine("("); int num = 0; foreach (DataFieldModel model in table.Fields) { if (num++ > 0) { sw.WriteLine(","); } sw.Write(string.Format(" {0}", FieldDefinition(model))); } sw.WriteLine(); sw.WriteLine(")"); sw.WriteLine("GO"); sw.WriteLine(); sw.WriteLine("------------------------------------------------------------------"); sw.WriteLine(string.Format("-- Create primary key for table [{0}]", table.Name)); sw.WriteLine("------------------------------------------------------------------"); sw.WriteLine(string.Format("alter table [dbo].[{0}] add", table.Name)); sw.WriteLine(string.Format("constraint [PK_{0}] primary key clustered", table.Name)); sw.WriteLine("("); num = 0; foreach (DataFieldModel model2 in table.PKFields) { if (num++ > 0) { sw.WriteLine(","); } sw.Write(string.Format(" [{0}]", model2.Name)); } sw.WriteLine(); sw.WriteLine(") on [primary]"); sw.WriteLine(); if (table.CKFields.Count > 0) { sw.WriteLine("------------------------------------------------------------------"); sw.WriteLine(string.Format("-- Create candidate key for table [{0}]", table.Name)); sw.WriteLine("------------------------------------------------------------------"); sw.WriteLine(string.Format("alter table [dbo].[{0}] add", table.Name)); sw.WriteLine(string.Format("constraint [UK_{0}] unique", table.Name)); sw.WriteLine("("); num = 0; foreach (DataFieldModel model3 in table.CKFields) { if (num++ > 0) { sw.WriteLine(","); } sw.Write(string.Format(" [{0}]", model3.Name)); } sw.WriteLine(); sw.WriteLine(") on [primary]"); sw.WriteLine(); } sw.WriteLine("------------------------------------------------------------------"); sw.WriteLine(string.Format("-- Extended properties for table [{0}]", table.Name)); sw.WriteLine("------------------------------------------------------------------"); ScriptTableProp(table, "MappingName", table.MappingName, sw); ScriptTableProp(table, m_DescriptionKey, table.Description, sw); foreach (DataFieldModel model4 in table.Fields) { ScriptFieldProp(model4, "Caption", model4.CaptionString, sw); ScriptFieldProp(model4, m_DescriptionKey, model4.Description, sw); } }
public static void SelectSp(DataEntityModel tableInfo, TextWriter sw) { string str = GetSpName(tableInfo.Parent, tableInfo, TableOperationType.Select); TraceInfoEvent.Raise(string.Format("Generating SP '{0}'.", str)); HeadingComment(sw, str, string.Format("Selects the specified {0} record.", tableInfo.MappingName)); ProcHead(sw, str); FieldList(sw, " @{0} {1}", tableInfo.PKFields); sw.WriteLine("as"); sw.WriteLine(" select"); FieldList(sw, " [{0}]", tableInfo.Fields); //sw.WriteLine(string.Format(" from [{0}] with (nolock)", tableInfo.MappingName)); sw.WriteLine(string.Format(" from [{0}] with (nolock)", tableInfo.MappingName)); sw.WriteLine(" where"); ConditionList(sw, " {0} = @{0}", tableInfo.PKFields); sw.WriteLine(); sw.WriteLine(" return @@rowcount"); sw.WriteLine("GO"); sw.WriteLine(); }
public override void DropScript(DataEntityModel table, TextWriter sw) { sw.WriteLine("------------------------------------------------------------------"); sw.WriteLine(string.Format("-- Drop the [{0}] table", table.Name)); sw.WriteLine("------------------------------------------------------------------"); sw.WriteLine("if exists (select * from dbo.sysobjects "); sw.WriteLine(string.Format(" where id = object_id(N'[dbo].[{0}]') and ", table.Name)); sw.WriteLine(" OBJECTPROPERTY(id, N'IsUserTable') = 1)"); sw.WriteLine(string.Format("drop table [{0}]", table.Name)); sw.WriteLine("GO"); sw.WriteLine(); }
public BusinessDocModel this[DataEntityModel de] { get { string documentName = de.Parent.GetDocumentName(de); return this[documentName]; } }
public override void GenerateSelectDispsetAllSp(DataEntityModel de, TextWriter sw) { Sql2000SpGenerator.SelectDispsetAllSp(de, sw); }
public static string GetOpName(TableOperationType type, DataEntityModel entity) { return (type + entity.MappingName); }
public override void GenerateUpdateSp(DataEntityModel de, TextWriter sw) { Sql2000SpGenerator.UpdateSp(de, sw); }
// Methods public BusinessDocModel(string name, DataEntityModel rootEntity) { m_Name = name; m_RootEntity = rootEntity; }
public override void GenerateSelectHeader(DataEntityModel de, TextWriter sw) { string str = de.Parent.SelectSpName(de); sw.Write(string.Format("PROCEDURE {0}(", str)); Oracle8SpGenerator.PackageHeaderFieldList(sw, "i{0} IN {1}", de.PKFields); sw.Write(", oresult OUT refCursor"); sw.WriteLine(");"); }