本文整理汇总了C#中Table.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Table.GetType方法的具体用法?C# Table.GetType怎么用?C# Table.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Table
的用法示例。
在下文中一共展示了Table.GetType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RecurSetPropertyValue
internal void RecurSetPropertyValue(string internalFieldName, Connection conn, string queryFieldName, Table table)
{
sTable map = conn.Pool.Mapping[table.GetType()];
foreach (sTableField fld in map.Fields)
{
if (fld.Name == internalFieldName)
{
if (fld.ExternalField == null)
table.SetField(fld.ClassProperty, conn[queryFieldName]);
else if (fld.Type == FieldType.ENUM)
{
PropertyInfo pi = table.GetType().GetProperty(fld.ClassProperty, Utility._BINDING_FLAGS);
if (pi == null)
pi = table.GetType().GetProperty(fld.ClassProperty, Utility._BINDING_FLAGS_WITH_INHERITANCE);
table.SetField(fld.ClassProperty, conn.GetEnum(pi.PropertyType, queryFieldName));
}
else
{
if (table.GetField(fld.ClassProperty) == null)
{
PropertyInfo pi = table.GetType().GetProperty(fld.ClassProperty, Utility._BINDING_FLAGS);
if (pi == null)
pi = table.GetType().GetProperty(fld.ClassProperty, Utility._BINDING_FLAGS_WITH_INHERITANCE);
Table t = (Table)pi.PropertyType.GetConstructor(Type.EmptyTypes).Invoke(new object[0]);
t._loadStatus = LoadStatus.Partial;
t = (Table)LazyProxy.Instance(t);
table.SetField(fld.Name, t);
}
RecurSetPropertyValue(fld.ExternalField, conn, queryFieldName, (Table)table.GetField(fld.Name));
}
break;
}
}
}
示例2: CopyValuesFrom
//called to copy values from an existing table object, this is done for table inheritance
internal void CopyValuesFrom(Table table)
{
ConnectionPool pool = ConnectionPoolManager.GetPool(table.GetType());
sTable mp = pool.Mapping[table.GetType()];
foreach (string prop in mp.Properties)
{
try{
this.SetField(prop, table.GetField(prop));
}catch (Exception e)
{
}
}
Type t = table.GetType().BaseType;
while (pool.Mapping.IsMappableType(t))
{
mp = pool.Mapping[t];
foreach (string prop in mp.Properties)
{
try
{
this.SetField(prop, table.GetField(prop));
}
catch (Exception e)
{
}
}
t = t.BaseType;
}
InitPrimaryKeys();
if (table.GetType() == this.GetType().BaseType)
this._isParentSaved = table.IsSaved;
}
示例3: SetExternalValues
//called to set values onto a table that is externally mapped to this current table
//this is used through lazy loading proxies by only setting the primary key fields.
private Table SetExternalValues(sTable map,string propertyName, Connection conn, out bool setValue,Table table)
{
setValue = false;
sTable eMap = conn.Pool.Mapping[table.GetType()];
sTableField[] flds = map[propertyName];
List<string> fProps = new List<string>(eMap.ForeignTableProperties);
Type ty = table.GetType().BaseType;
while (conn.Pool.Mapping.IsMappableType(ty))
{
foreach (string str in conn.Pool.Mapping[ty].ForeignTableProperties)
{
if (!fProps.Contains(str))
fProps.Add(str);
}
ty = ty.BaseType;
}
foreach (string prop in eMap.PrimaryKeyProperties)
{
if (fProps.Contains(prop) && !eMap.IsEnumProperty(prop))
{
PropertyInfo pi = table.GetType().GetProperty(prop, Utility._BINDING_FLAGS);
if (pi == null)
pi = table.GetType().GetProperty(prop, Utility._BINDING_FLAGS_WITH_INHERITANCE);
Table t = (Table)pi.PropertyType.GetConstructor(Type.EmptyTypes).Invoke(new object[0]);
t._loadStatus = LoadStatus.Partial;
t = (Table)LazyProxy.Instance(t);
foreach (sTableField f in eMap[prop])
{
foreach (sTableField fld in flds)
{
if (fld.ExternalField == f.Name)
{
if (conn.ContainsField(fld.Name) && !conn.IsDBNull(conn.GetOrdinal(fld.Name)))
{
RecurSetPropertyValue(f.ExternalField, conn, fld.Name, t);
}
break;
}
}
}
if (!t.AllPrimaryKeysNull)
{
t.InitPrimaryKeys();
table.SetField(prop, t);
setValue = true;
}
}
else
{
foreach (sTableField f in eMap[prop])
{
foreach (sTableField fld in flds)
{
if (fld.ExternalField == f.Name)
{
if (conn.ContainsField(fld.Name)&&!conn.IsDBNull(conn.GetOrdinal(fld.Name))){
if (f.Type == FieldType.ENUM)
table.SetField(prop, conn.Pool.GetEnumValue(table.GetType().GetProperty(f.ClassProperty,Utility._BINDING_FLAGS_WITH_INHERITANCE).PropertyType, (int)conn[fld.Name]));
else
table.SetField(prop, conn[fld.Name]);
setValue = true;
}
break;
}
}
}
}
}
return table;
}
示例4: GetTableProperties
private PropertyInfo[] GetTableProperties(Table table)
{
return table.GetType().GetProperties().Where(
p =>
{
var columnType = typeof(Column);
return p.PropertyType == columnType;
}).ToArray();
}