Base class for native queries.
For a list of all members of this type, see Predicate Members.
System.Object
com.db4o.query.Predicate
Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.
Base class for native queries.
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
IList <Cat> cats = db.Query <Cat> (delegate(Cat cat) {
return cat.Name == "Occam";
});
// Java JDK 5
List <Cat> cats = db.query(new Predicate<Cat>() {
public boolean match(Cat cat) {
return cat.getName().equals("Occam");
}
});
// Java JDK 1.2 to 1.4
List cats = db.query(new Predicate() {
public boolean match(Cat cat) {
return cat.getName().equals("Occam");
}
});
// Java JDK 1.1
ObjectSet cats = db.query(new CatOccam());
public static class CatOccam extends Predicate {
public boolean match(Cat cat) {
return cat.getName().equals("Occam");
}
});
// C# .NET 1.1
IList cats = db.Query(new CatOccam());
public class CatOccam : Predicate {
public boolean Match(Cat cat) {
return cat.Name == "Occam";
}
});
Namespace: com.db4o.query
Assembly: db4o (in db4o.dll)
Predicate Members | com.db4o.query Namespace