当前位置: 首页>>代码示例>>C#>>正文


C# Table.GetType方法代码示例

本文整理汇总了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;
         }
     }
 }
开发者ID:marquismark,项目名称:dbpro-orm,代码行数:34,代码来源:Table.cs

示例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;
		}
开发者ID:marquismark,项目名称:dbpro-orm,代码行数:35,代码来源:Table.cs

示例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;
 }
开发者ID:marquismark,项目名称:dbpro-orm,代码行数:72,代码来源:Table.cs

示例4: GetTableProperties

 private PropertyInfo[] GetTableProperties(Table table)
 {
     return table.GetType().GetProperties().Where(
         p =>
         {
             var columnType = typeof(Column);
             return p.PropertyType == columnType;
         }).ToArray();
 }
开发者ID:codeinsiders,项目名称:sharpql,代码行数:9,代码来源:AssignListBuilder.cs


注:本文中的Table.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。