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 |
|---|
[Persistent("CALLS", PoolSize = 20)] public class Call { // The class contains an ObjectHolder and a <see cref="T:Chili.Opf3.Relations.RelationAttribute">RelationAttribute</see> // that specifies the relation between the parent object and the // related objects. [Relation("UserId", "Id", SaveOrder = SaveOrders.ChildFirst)] private ObjectHolder<User> _user = new ObjectHolder<User>(); public Call() { _user.FetchingStorageRecord += PersistentTypeSelector(MySelection); } 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); } // The User property accesses the InnerObject property to get // the User object or to set a new one. public User User { get { return _user.InnerObject; } set { _user.InnerObject = value; } } // ... Other properties and code. } // ... Call call = context.GetObject<Call>("Name = {0}", "Call 1"); User user = call.User; if (user.GetType() == typeof(User1)) Console.WriteLine("User1 found."); else Console.WriteLine("User found."); |
Remarks
Requirements
Platforms: Windows 2000, Windows XP family, Windows Server 2003 family, Windows Vista family
See Also