Exemplo n.º 1
0
 public override void GenerateSelectSp(DataEntityModel de, TextWriter sw)
 {
     Oracle8SpGenerator.SelectSp(de, sw);
 }
Exemplo n.º 2
0
 // Methods
 public TableOperation(TableOperationType type, DataEntityModel entity)
 {
     m_Type = type;
       m_Table = entity;
       base.m_DataLayer = entity.Parent;
 }
Exemplo n.º 3
0
 public BusinessDocModel NewDocument(string docName, DataEntityModel de)
 {
     BusinessDocModel dm = new BusinessDocModel(docName, de);
       Add(dm);
       dm.Parent = this;
       return dm;
 }
Exemplo n.º 4
0
 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();
 }
Exemplo n.º 5
0
 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();
 }
Exemplo n.º 6
0
 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();
 }
Exemplo n.º 7
0
 public static string GetSpName(DataAccessModel daLayer, DataEntityModel de, TableOperationType opType)
 {
     return string.Format("{0}{1}{2}", daLayer.Prefix, de.MappingName, opType);
 }
Exemplo n.º 8
0
 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);
 }
Exemplo n.º 9
0
 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();
 }
Exemplo n.º 10
0
 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();
       }
 }
Exemplo n.º 11
0
 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();
 }
Exemplo n.º 12
0
 public override string UpdateSpName(DataEntityModel de)
 {
     return Oracle8SpGenerator.GetSpName(de.Parent, de, "Update");
 }
Exemplo n.º 13
0
 public override string SelectSpName(DataEntityModel de)
 {
     return Oracle8SpGenerator.GetSpName(de.Parent, de, "Select");
 }
Exemplo n.º 14
0
 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(");");
 }
Exemplo n.º 15
0
 public override string SelectDispsetAllSpName(DataEntityModel de)
 {
     return Sql2000SpGenerator.GetSpName(de.Parent, de, TableOperationType.SelectDispsetAll);
 }
Exemplo n.º 16
0
 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();
 }
Exemplo n.º 17
0
 public override string UpdateSpName(DataEntityModel de)
 {
     return Sql2000SpGenerator.GetSpName(de.Parent, de, TableOperationType.Update);
 }
Exemplo n.º 18
0
 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();
 }
Exemplo n.º 19
0
 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();
 }
Exemplo n.º 20
0
 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();
 }
Exemplo n.º 21
0
 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();
 }
Exemplo n.º 22
0
 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);
       }
 }
Exemplo n.º 23
0
 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();
 }
Exemplo n.º 24
0
 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();
 }
Exemplo n.º 25
0
 public BusinessDocModel this[DataEntityModel de]
 {
     get
       {
     string documentName = de.Parent.GetDocumentName(de);
     return this[documentName];
       }
 }
Exemplo n.º 26
0
 public override void GenerateSelectDispsetAllSp(DataEntityModel de, TextWriter sw)
 {
     Sql2000SpGenerator.SelectDispsetAllSp(de, sw);
 }
Exemplo n.º 27
0
 public static string GetOpName(TableOperationType type, DataEntityModel entity)
 {
     return (type + entity.MappingName);
 }
Exemplo n.º 28
0
 public override void GenerateUpdateSp(DataEntityModel de, TextWriter sw)
 {
     Sql2000SpGenerator.UpdateSp(de, sw);
 }
Exemplo n.º 29
0
 // Methods
 public BusinessDocModel(string name, DataEntityModel rootEntity)
 {
     m_Name = name;
       m_RootEntity = rootEntity;
 }
Exemplo n.º 30
0
 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(");");
 }