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("USER", PoolSize = 50)] public class User { // The class contains an ObjectSetHolder and a RelationAttribute // that specifies the relation between the parent object and the // related objects. It demonstrates also how to use a condition to // delimit the items in the list and to sort the result. [Relation("Id", "UserId")] private ObjectSetHolder<Call> _calls = new ObjectSetHolder<Call>("Duration < {0} SortBy Duration Asc", "50"); public User() { _calls.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); } public ObjectSet<Call> Calls { get { return _calls.InnerObject; } set { _calls.InnerObject = value; } } // ... Other properties and code. } // ... ObjectSet<User> objectSet = context.GetObjectSet<User>(); foreach(User user in objectSet) { foreach(Call call in user.Calls) { if (call.GetType() == typeof(Call1)) Console.WriteLine("Call1 found."); else Console.WriteLine("Call found."); } } |
Remarks
Requirements
Platforms: Windows 2000, Windows XP family, Windows Server 2003 family, Windows Vista family
See Also