Class GenericTableInfo
'Generic' tableinfo class, that can be used to represent any table that is defined in the runtime dictionary in the database. These can be both system tables and user-defined tables. It does not provide a typed interface to the individual fields.
Implements
Inherited Members
Namespace: SuperOffice.CRM.Data
Assembly: SoDataBase.dll
Syntax
public class GenericTableInfo : TableInfo, ICloneable
Remarks
When the table layout is known in advance, either because a table is defined by SuperOffice, or because a tableinfo has been generated by the Web Service, a typed tableinfo is to be preferred. However, sometimes it is necessary to work in a more generic manner, and that is where this class is useful.
A GenericTableInfo can be created by name through the TablesInfo.GetTableInfo(SoTable) method. Note that GetTableInfo will return a typed object for Superoffice system tables. Since this class does not provide members for fields, one must use the FindField method to look up fields by name, or simply use the All property to get an array of fields and index by position. This class can be used anywhere a TableInfo is expected - in queries, etc.TableInfo myTab = TablesInfo.GetTableInfo( "userDefinedTable" );
Select sql = S.NewSelect();
FieldInfo myFieldInfo = myTab.FindField( "myField" );
sql.ReturnFields.Add( myFieldInfo );
sql.Restriction = myTab.FindField( "theKey" ).Equal( S.Parameter( 2 ) );
using( QueryExecutionHelper qeh = new QueryExecutionHelper( sql ) )
{
while( qeh.Reader.Read() )
{
int myField = qeh.Reader.GetInt32( myFieldInfo );
// use the value
}
}
The example above fetches the int field 'myField' from 'userDefinedTable', restricting
the rows to those that have 'theKey' equal to 2.