本文整理汇总了C#中Connection.GetInt32方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.GetInt32方法的具体用法?C# Connection.GetInt32怎么用?C# Connection.GetInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection.GetInt32方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetEnum
internal object GetEnum(Type type, string name,Connection conn)
{
return _pool.GetEnumValue(type, conn.GetInt32(TranslateFieldIndex(GetOrdinal(name))));
}
示例2: _SyncMissingValues
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: GetValue
internal object GetValue(int i,Connection conn){
if (IsDBNull(i,conn))
return null;
if (_tableFieldCounts.ContainsKey(i))
{
Table t = (Table)LazyProxy.Instance(_tableFields[_fieldNames[i]].GetConstructor(System.Type.EmptyTypes).Invoke(new object[0]));
sTableField[] flds = conn.Pool.Mapping[_tableFields[_fieldNames[i]]].Fields;
int index = 0;
i = TranslateFieldIndex(i);
foreach (sTableField fld in flds)
{
PropertyInfo pi = t.GetType().GetProperty(fld.ClassProperty, Utility._BINDING_FLAGS_WITH_INHERITANCE);
if (!pi.PropertyType.IsArray || !pi.PropertyType.Equals(typeof(byte[])))
{
if (conn.Pool.Mapping.IsMappableType(pi.PropertyType) && !Utility.IsEnum(pi.PropertyType))
{
if (!conn.IsDBNull(i + index))
{
if (t.GetField(pi.Name) == null)
{
Table tmp = (Table)LazyProxy.Instance(pi.PropertyType.GetConstructor(Type.EmptyTypes).Invoke(new object[0]));
tmp.LoadStatus = LoadStatus.Partial;
t.SetField(fld.Name, tmp);
}
Table tbl = (Table)t.GetField(pi.Name);
foreach (sTableField f in conn.Pool.Mapping[tbl.GetType()].Fields)
{
if (fld.ExternalField == f.Name)
{
t.RecurSetPropertyValue(f.Name, conn, conn.GetName(i + index), tbl);
index++;
break;
}
}
}
else
index++;
}
else
{
if (!conn.IsDBNull(i + index))
{
if (Utility.IsEnum(pi.PropertyType))
t.SetField(fld.ClassProperty, conn.Pool.GetEnumValue(pi.PropertyType, conn.GetInt32(i + index)));
else
t.SetField(fld.ClassProperty, conn[i + index]);
}
index++;
}
}
}
t.LoadStatus = LoadStatus.Complete;
return t;
}
else if (_enumFields.ContainsKey(i))
{
return _pool.GetEnumValue(_enumFields[i], conn.GetInt32(TranslateFieldIndex(i)));
}else
return conn.GetValue(TranslateFieldIndex(i));
}
示例4: LoadEnumsFromTable
internal void LoadEnumsFromTable(Type t, Connection conn)
{
t = (t.IsGenericType ? t.GetGenericArguments()[0] : t);
conn.ExecuteQuery("SELECT * FROM " + _enumTableMaps[t]);
Dictionary<string, int> vals = new Dictionary<string, int>();
while (conn.Read())
vals.Add(conn[1].ToString(), conn.GetInt32(0));
conn.Close();
if (_enumValuesMap.ContainsKey(t))
_enumValuesMap.Remove(t);
if (_enumReverseValuesMap.ContainsKey(t))
_enumReverseValuesMap.Remove(t);
if (vals.Count == 0)
InsertEnumIntoTable(t, conn);
else
{
foreach (string str in Enum.GetNames(t))
{
if (!vals.ContainsKey(str))
{
vals = _SyncMissingValues(vals, t, conn);
break;
}
}
_enumValuesMap.Add(t, vals);
Dictionary<int, string> revs = new Dictionary<int, string>();
foreach (string str in vals.Keys)
revs.Add(vals[str], str);
_enumReverseValuesMap.Add(t, revs);
}
}