Ejemplo n.º 1
0
 private void AssignColumnPropertyNames()
 {
     foreach (SchemaObject obj2 in this.Objects.Values)
     {
         DotNetNameBank bank = new DotNetNameBank();
         foreach (Column column in obj2.Columns.Values)
         {
             bank.RegisterName(column.ColumnName);
         }
         HashSet<string> set = new HashSet<string>();
         foreach (Column column in obj2.Columns.Values.ToArray<Column>())
         {
             string uniqueDotNetName = bank.GetUniqueDotNetName(column.ColumnName);
             if (uniqueDotNetName == null)
             {
                 obj2.Columns.Remove(column.ColumnID);
             }
             else
             {
                 column.PropertyName = this.TransformIdentifier(uniqueDotNetName);
                 if (column.PropertyName == column.ClrObjectName)
                 {
                     if (bank.ContainsDotNetName("Content"))
                     {
                         obj2.Columns.Remove(column.ColumnID);
                     }
                     else
                     {
                         column.PropertyName = "Content";
                     }
                 }
                 if (set.Contains(column.PropertyName))
                 {
                     obj2.Columns.Remove(column.ColumnID);
                 }
                 else
                 {
                     set.Add(column.PropertyName);
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 private void ReadRoutineParameters(IEnumerable<Parameter> routineParameters)
 {
     if (routineParameters != null)
     {
         SchemaObject obj2 = null;
         string str = null;
         foreach (Parameter parameter in routineParameters)
         {
             string key = parameter.RoutineSchema + "." + parameter.RoutineName;
             if (key != str)
             {
                 if (!this.Objects.TryGetValue(key, out obj2))
                 {
                     obj2 = null;
                 }
                 str = key;
             }
             if (obj2 != null)
             {
                 if (!parameter.IsValid)
                 {
                     this.Objects.Remove(key);
                 }
                 else if (parameter.IsResult)
                 {
                     obj2.ReturnInfo = parameter;
                 }
                 else
                 {
                     obj2.Parameters.Add(parameter);
                 }
             }
         }
         foreach (SchemaObject obj3 in this.Objects.Values)
         {
             DotNetNameBank bank = new DotNetNameBank();
             foreach (Parameter parameter2 in obj3.Parameters)
             {
                 bank.RegisterName(parameter2.ParamName);
             }
             foreach (Parameter parameter2 in obj3.Parameters.ToArray<Parameter>())
             {
                 string uniqueDotNetName = bank.GetUniqueDotNetName(parameter2.ParamName);
                 if (uniqueDotNetName == null)
                 {
                     obj2.Parameters.Remove(parameter2);
                 }
                 else
                 {
                     parameter2.ClrName = uniqueDotNetName;
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 private void ReadColumns(IEnumerable<Column> columns)
 {
     string str2;
     Dictionary<string, string> dictionary = new Dictionary<string, string>();
     List<Column> list = new List<Column>(0x1000);
     foreach (Column column in columns)
     {
         string str;
         list.Add(column);
         if (dictionary.TryGetValue(column.ObjectName, out str))
         {
             if ((str != null) && (str != column.SchemaName))
             {
                 dictionary[column.ObjectName] = null;
             }
         }
         else
         {
             dictionary.Add(column.ObjectName, column.SchemaName);
         }
     }
     DotNetNameBank bank = new DotNetNameBank();
     foreach (Column column in list)
     {
         str2 = dictionary[column.ObjectName];
         string sqlName = (((str2 != null) || (column.SchemaName == "dbo")) || (column.SchemaName == "")) ? column.ObjectName : (column.SchemaName + "_" + column.ObjectName);
         bank.RegisterName(sqlName);
     }
     HashSet<string> set = new HashSet<string>();
     foreach (Column column in list)
     {
         if (dictionary.TryGetValue(column.ObjectName, out str2))
         {
             string str4 = (((str2 != null) || (column.SchemaName == "dbo")) || (column.SchemaName == "")) ? column.ObjectName : (column.SchemaName + "_" + column.ObjectName);
             string uniqueDotNetName = bank.GetUniqueDotNetName(str4);
             if (uniqueDotNetName != null)
             {
                 if ((column.ObjectKind == DbObjectKind.Table) || (column.ObjectKind == DbObjectKind.View))
                 {
                     uniqueDotNetName = this.TransformIdentifier(uniqueDotNetName);
                 }
                 string key = column.SchemaName + "." + column.ObjectName;
                 if (!this.Objects.ContainsKey(key))
                 {
                     if (set.Contains(uniqueDotNetName))
                     {
                         continue;
                     }
                     set.Add(uniqueDotNetName);
                     SchemaObject obj2 = SchemaObject.Create(column, uniqueDotNetName);
                     this.Objects.Add(key, obj2);
                 }
                 SchemaObject obj3 = this.Objects[key];
                 if (column.IsKey)
                 {
                     obj3.HasKey = true;
                 }
                 column.ClrObjectName = uniqueDotNetName;
                 column.Object = obj3;
                 obj3.Columns[column.ColumnID] = column;
             }
         }
     }
     foreach (SchemaObject obj2 in this.Objects.Values)
     {
         obj2.OriginalName = obj2.PropertyName;
         if (this.Pluralize && obj2.IsPluralizable)
         {
             string pluralName = StringUtil.GetPluralName(obj2.PropertyName);
             if (!set.Contains(pluralName))
             {
                 obj2.PropertyName = pluralName;
             }
         }
     }
 }