T
Chili.Opf3 Send comments on this topic.
Generic GetObject(ICustomPersister,IQuery) Method
See Also  Example
Chili.Opf3 Namespace > ObjectContext Class > GetObject Method : Generic GetObject(ICustomPersister,IQuery) Method




customPersister
The class implementing the ICustomPersister interface.
query
An instance of a class that implements the IQuery interface. This query is compiled and used to retrieve the object from the storage.
Populates a class implementing the ICustomPersister interface with data.

Syntax

Visual Basic (Declaration) 
Overloads Public Overridable Function GetObject(Of T)( _
   ByVal customPersister As ICustomPersister, _
   ByVal query As IQuery _
) As ICustomPersister
Visual Basic (Usage)Copy Code
Dim instance As ObjectContext
Dim customPersister As ICustomPersister
Dim query As IQuery
Dim value As ICustomPersister
 
value = instance.GetObject(Of T)(customPersister, query)
C# 
public virtual ICustomPersister GetObject<T>( 
   ICustomPersister customPersister,
   IQuery query
)
Managed Extensions for C++ 
public: virtual ICustomPersister* GetObject<T>( 
   ICustomPersister* customPersister,
   IQuery* query
) 
C++/CLI 
public:
virtual ICustomPersister^ GetObjectgeneric<typename T>
( 
   ICustomPersister^ customPersister,
   IQuery^ query
) 

Parameters

customPersister
The class implementing the ICustomPersister interface.
query
An instance of a class that implements the IQuery interface. This query is compiled and used to retrieve the object from the storage.

Type Parameters

T

Return Value

The first object implementing the ICustomPersister interface.

Example

The following example introduces to the use of the GetObject routine with the ICustomPersister interface.
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. 
  
// Populates the given ObjectSet with data. 
ObjectSet<User> = context.GetObject<User>(new ObjectSet<User>(),  
    "Name like {0} SortBy Name Asc", "%mith%"); 
    

Remarks

Populates the class implementing the ICustomPersister with data from the storage. The class gets the control on how to load the objects from the storage. A query is also given to have the object loaded the objects matching the query. There is no guarantuee that the object loads exactly the objects returned by the query, since it controls the loading process by itself.

Requirements

Platforms: Windows 2000, Windows XP family, Windows Server 2003 family, Windows Vista family

See Also