Allows to specify a method that is invoked each time before a persistent object is created.
Syntax
| Visual Basic (Usage) | Copy Code |
|---|
Dim instance As New PersistentTypeSelector(AddressOf HandlerMethod)
|
Parameters
- sender
- The object who invoked the delegate.
- e
- An instance of the FetchingStorageRecordEventArgs
class containing all necessary properties to change the type or have the current item ignored.
Example
The following sample shows the usage of this delegate in some methods of the
ObjectContext.
| C# | Copy Code |
|---|
// Creates a new ObjectContext that uses an MsSql Server as storage. ObjectContext context = new ObjectContext(new MsSqlStorage("sa", "", "localhost", "application")); // ... Other code. // Get the ObjectSet with user matching the name and sorting them by name. ObjectSet<User> objectSet = context.GetObjectSet<User>(new PersistentTypeSelector(MySelection)); // Loop through all items and do something. foreach(User user in objectSet) { // Do something. } // ... 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; } else { // Have a persistent of type User created. e.Type = typeof(User); } } |
Remarks
Requirements
Namespace: Chili.Opf3
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: Chili.Opf3 (in Chili.Opf3.dll)
See Also