Version

ReadObject(IDataReader,ScheduleDataBinding,Object) Method

Reads a composite instance from the WebSchedule object model bound from the data model.
Syntax
'Declaration
 
Protected Overloads Function ReadObject( _
   ByVal reader As IDataReader, _
   ByVal binding As ScheduleDataBinding, _
   ByVal compositeInstance As Object _
) As Object
protected object ReadObject( 
   IDataReader reader,
   ScheduleDataBinding binding,
   object compositeInstance
)

Parameters

reader
An IDataReader-implementation that has had Read called on it.
binding
A registered instance of any subclass of ScheduleDataBinding that is used when identifying the Type being bound across the data model into the WebSchedule object model
compositeInstance
Optional. An instance that has already been partially initialized by an earlier call to ReadRecord. May be null (or Nothing in Visual Basic .NET) when this composition is not required (i.e., using stored procedures).

Return Value

An instance of a WebSchedule object model type, with values assigned to it's properties from those in the data record that has been read. The caller may confidently type cast this instance to the expected return type in the WebSchedule object model for which the supplied binding was responsible. For example, if ResourceBinding were passed, then it is safe to assume the CLR Type of the object returned by ReadRecord would be a Resource.
Remarks

Inheritors implementing their own operations on a custom data provider would invoke ReadRecord within the loop that calls Read on reader until the result set of an SQL command has been exhausted. Each call binds the database record to the instance in the WebSchedule object model represented by binding. This instance may have been created by a call to CreateInstance or it may re-use a previously constructed compositeInstance.

When implementing a composite object that involves multiple ScheduleDataBindings (e.g., because to fully populate it's properties, multiple tables in the data model may need to be read), the caller may pass a pre-constructed compositeInstance (it's the caller's responsibility to create this instance in advance). When supplied, ReadRecord will not call CreateInstance, and will instead populate bound values from this record into the compositeInstance. Generally, the additional complexity of composite instances are only necessary when using dynamic SQL commands. Developers are encouraged to avoid implementing this complexity in their custom data provider by instead using stored procedures which can compose values from multiple data tables in a single record, when supported.

Because subclasses of ScheduleDataBinding inherit all binding member properties from their base class, inheritors do not need to use composite data binding to deal with inheritance. A highly derived ScheduleDataBinding will bind public properties of its base class(es), for example, an AppointmentBinding is sufficient to data-bind both Activity (the base class of Appointment) and Appointment properties. It is not necessary to data bind using both the ActivityBinding and the AppointmentBinding.

The instance of the ScheduleDataBinding passed to binding must match the one a custom data provider has registered by calling Add (or AddRange) on DataBindings. If the same object reference is not found in DataBindings as is passed to the ReadRecord method, then metadata describing how data binding between the data model and object model should be performed will not be found, and this method fails. This metadata is cached the first time a particular ScheduleDataBinding gets added to the DataBindings collection because the initial map generation between object and data models is a relatively costly operation. Therefore, changes made to the ScheduleDataBinding instance between the time it was first added to the DataBindings and the time ReadRecord is called may not be reflected by the data bind.

ReadObject
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also