T
Chili.Opf3 Send comments on this topic.
Generic GetObjectSearcher Method
See Also  Example
Chili.Opf3 Namespace > ObjectContext Class : Generic GetObjectSearcher Method




Returns a new generic ObjectSearcher class.

Syntax

Visual Basic (Declaration) 
Public Function GetObjectSearcher(Of T)() As ObjectSearcher(Of T)
Visual Basic (Usage)Copy Code
Dim instance As ObjectContext
Dim value As ObjectSearcher(Of T)
 
value = instance.GetObjectSearcher(Of T)()
C# 
public ObjectSearcher<T> GetObjectSearcher<T>()
Managed Extensions for C++ 
public: ObjectSearcher<T>* GetObjectSearcher<T>(); 
C++/CLI 
public:
ObjectSearcher<T>^ GetObjectSearchergeneric<typename T>
(); 

Type Parameters

T

Return Value

A generic ObjectSearcher class that allows you to search for persistent objects.

Example

The following example shows how to get and use an ObjectSearcher.
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 ObjectSearcher class for user. 
ObjectSearcher<User> searcher = context.GetObjectSearcher<User>(); 
// Find all user matching the name. The result is sorted by name. 
ObjectSet<User> objectSet = searcher.FindAll("Name like {0} SortBy Name Asc", "%mith%"); 
  
foreach(User user in objectSet) 

    // Do something. 

    

Remarks

An ObjectSearcher is used to find items in the storage, by applying conditions on the FindAll routine of the class. By deriving form ObjectSearcher and overriding the FindAll routines you can implement your own load mechanism for your persistent objects.

Requirements

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

See Also