Event is fired before the data from the storage is used to populate an object.
Syntax
Event Data
The event handler receives an argument of type FetchingStorageRecordEventArgs containing data related to this event. The following FetchingStorageRecordEventArgs properties provide information specific to this event.
| Property | Description |
|---|
| DataRecord |
Returns the current IDataRecord representing the current
row or item of the storage.
|
| Ignore |
Specifies whether to ignore the current row or item of the storage. Ignoring the current means
that no persistent object is created and the framework tries to process the next item.
|
| Type |
Specifies the type of the persistent object that is created.
|
Example
The following example introduces to the use of the FecthingStorageRecord event.
| C# | Copy Code |
|---|
ObjectReader<User> reader = context.GetObjectReader<User>(); // Register the event. reader.FetchingStorageRecord += new PersistentTypeSelector(MySelection); // Loop trough all items. foreach (User user in reader) { if (user.GetType() == typeof(User1)) Console.WriteLine("User1 found."); else Console.WriteLine("User found."); } // ... private void MySelection(object sender, FetchingStorageRecordEventArgs e) { if (e.DataRecord["Type"] == "1") { // Switch the type of the persistent that is created to User1. e.Type = typeof(User1); } else if ((bool)e.DataRecord["Ignore"]) { // Tell the framework to ignore this item. e.Ignore = true; } // Have a persistent of type User created. e.Type = typeof(User); } |
Remarks
Requirements
Platforms: Windows 2000, Windows XP family, Windows Server 2003 family, Windows Vista family
See Also