示例#1
0
 internal void InsertEnumIntoTable(Type t, Connection conn)
 {
     t = (t.IsGenericType ? t.GetGenericArguments()[0] : t);
     foreach (string str in Enum.GetNames(t))
     {
         conn.ExecuteNonQuery(string.Format("INSERT INTO {0}({1}) VALUES({2});",
                 _enumTableMaps[t],
                 _pool.Translator.GetEnumValueFieldName(t, conn),
                 conn.CreateParameterName("value")),
             new System.Data.IDbDataParameter[]{conn.CreateParameter(conn.CreateParameterName("value"),str)});
     }
     conn.Commit();
     LoadEnumsFromTable(t, conn);
 }
示例#2
0
 private Dictionary<string, int> _SyncMissingValues(Dictionary<string, int> vals, Type t, Connection conn)
 {
     t = (t.IsGenericType ? t.GetGenericArguments()[0] : t);
     string[] keys = new string[vals.Count];
     vals.Keys.CopyTo(keys, 0);
     foreach (string str in Enum.GetNames(t))
     {
         if (!vals.ContainsKey(str))
         {
             conn.ExecuteNonQuery(string.Format("INSERT INTO {0}({1}) VALUES({2});",new object[]{ 
                 _enumTableMaps[t],
                 _pool.Translator.GetEnumValueFieldName(t, conn),
                 conn.CreateParameterName("value")}),
             new System.Data.IDbDataParameter[]{
                         conn.Pool.CreateParameter(conn.CreateParameterName("id"),null,Org.Reddragonit.Dbpro.Structure.Attributes.FieldType.INTEGER,4),
                         conn.CreateParameter(conn.CreateParameterName("value"),str)
                     });
             conn.ExecuteQuery("SELECT ID FROM " + _enumTableMaps[t] + " WHERE " + _pool.Translator.GetEnumValueFieldName(t, conn) + " = " + conn.CreateParameterName("value"),
                 new IDbDataParameter[]{
                     conn.CreateParameter(conn.CreateParameterName("value"),str)
                 });
             conn.Read();
             vals.Add(str, conn.GetInt32(0));
             conn.Close();
         }
     }
     return vals;
 }
示例#3
0
 internal void InsertToDB(Type t, int id, string value, Connection c)
 {
     t = (t.IsGenericType ? t.GetGenericArguments()[0] : t);
     c.ExecuteNonQuery("INSERT INTO " + _enumTableMaps[t] + " VALUES(" + c.CreateParameterName("id") + "," + c.CreateParameterName("value") + ");",
                     new System.Data.IDbDataParameter[]{
                         c.Pool.CreateParameter(c.CreateParameterName("id"),id),
                         c.Pool.CreateParameter(c.CreateParameterName("value"),value)
                     });
 }