[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]
Assembly: Db4objects.Db4o (in Db4objects.Db4o.dll)
Native Query Interface.
Namespace: Db4objects.Db4o
Assembly: Db4objects.Db4o (in Db4objects.Db4o.dll)
Syntax
Visual Basic (Declaration) |
---|
Function Query ( _ predicate As Predicate _ ) As IObjectSet |
C# |
---|
IObjectSet Query ( Predicate predicate ) |
Visual C++ |
---|
IObjectSet^ Query ( Predicate^ predicate ) |
Parameters
- predicate
- Db4objects.Db4o.Query.Predicate
the Db4objects.Db4o.Query.Predicate containing the native query expression.
Return Value
the Db4objects.Db4o.IObjectSet returned by the query.
Remarks
Native Query Interface.
Native Queries allow typesafe, compile-time checked and refactorable querying, following object-oriented principles. Native Queries expressions are written as if one or more lines of code would be run against all instances of a class. A Native Query expression should return true to mark specific instances as part of the result set. db4o will attempt to optimize native query expressions and execute them against indexes and without instantiating actual objects, where this is possible.
The syntax of the enclosing object for the native query expression varies, depending on the language version used. Here are some examples, how a simple native query will look like in some of the programming languages and dialects that db4o supports:
Summing up the above:
In order to run a Native Query, you can
- use the delegate notation for .NET 2.0.
- extend the Predicate class for all other language dialects
A class that extends Predicate is required to implement the #Match() / #Match() method, following the native query conventions:
- The name of the method is "#Match()" (Java) / "#Match()" (.NET).
- The method must be public public.
- The method returns a boolean.
- The method takes one parameter.
- The Type (.NET) / Class (Java) of the parameter specifies the extent.
- For all instances of the extent that are to be included into the resultset of the query, the match method should return true. For all instances that are not to be included, the match method should return false.
Native Queries allow typesafe, compile-time checked and refactorable querying, following object-oriented principles. Native Queries expressions are written as if one or more lines of code would be run against all instances of a class. A Native Query expression should return true to mark specific instances as part of the result set. db4o will attempt to optimize native query expressions and execute them against indexes and without instantiating actual objects, where this is possible.
The syntax of the enclosing object for the native query expression varies, depending on the language version used. Here are some examples, how a simple native query will look like in some of the programming languages and dialects that db4o supports:
![]() | |
---|---|
// C# .NET 2.0 |
Summing up the above:
In order to run a Native Query, you can
- use the delegate notation for .NET 2.0.
- extend the Predicate class for all other language dialects
A class that extends Predicate is required to implement the #Match() / #Match() method, following the native query conventions:
- The name of the method is "#Match()" (Java) / "#Match()" (.NET).
- The method must be public public.
- The method returns a boolean.
- The method takes one parameter.
- The Type (.NET) / Class (Java) of the parameter specifies the extent.
- For all instances of the extent that are to be included into the resultset of the query, the match method should return true. For all instances that are not to be included, the match method should return false.