Chili.Opf3 Send comments on this topic.
IPersistentQueriesProvider Interface
See Also  Members   Example
Chili.Opf3 Namespace : IPersistentQueriesProvider Interface




An interface that is implemented to create custom queries for a persistent object's insert, update and delete operations.

Syntax

Visual Basic (Declaration) 
Public Interface IPersistentQueriesProvider 
Visual Basic (Usage)Copy Code
Dim instance As IPersistentQueriesProvider
C# 
public interface IPersistentQueriesProvider 
Managed Extensions for C++ 
public __gc __interface IPersistentQueriesProvider 
C++/CLI 
public interface class IPersistentQueriesProvider 

Example

This example shows how to implement the IPersistentQueriesProvider interface and how to register it with the ObjectContext.
C#Copy Code
public sealed class CallQueriesProvider : IPersistentQueriesProvider 

    public IQuery GetInsertQuery(IStorage storage, object persistent) 
    { 
        // Return the null to have the framework create the query. 
        return null; 
    } 
 
    public IQuery GetUpdateQuery(IStorage storage, IQuery query, object persistent) 
    { 
        Call c = (Call)persistent; 
        // Check if the storage is the MsSqlStorage. 
        if (storage is MsSqlStorage) 
        { 
            // If that's true, create a custom query and return that query. 
            return new SqlQuery("UPDATE CALLS SET DURATION = {0} WHERE ID = {1}", c.Duration, c.ID); 
        } 
        // Otherwise return null. 
        return null; 
    } 
 
    public IQuery GetDeleteQuery(IStorage storage, IQuery query, object persistent) 
    { 
        // Return the null to have the framework create the query. 
        return null; 
    } 
 
    // Return the type of persistent this class has been created for. 
    public Type PersistentType 
    { 
        get { return typeof(Call); } 
    } 

 
// ... Other code. 
 
// Register the provider with the ObjectContext instance. 
context.PersistentQueriesProviders.Add(new CallQueriesProvider());

Remarks

This interface is implemented to create custom queries for a persistent's insert, update and delete operations. The interface contains a method for each operation: The class may return an own query or return the query that is created by the framework. It's not required that a custom query is created for each operation.

It's also required to specify the persistent's type that this class is created for! Each class can only be used for one given persistent object type.

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