The answers provided by John, Jared, and the ISU use the query after example, which is a largely unused DB4o query mechanism, and could potentially be deprecated in the future.
The preferred DB4O query methods for .NET are native queries and LINQ.
// Query for all Pilots using DB4O native query: var result = db.Query<Pilot>();
Or, alternatively, using Linq-to-DB4O:
// Query for all Pilots using LINQ var result = from Pilot p in db select p;
Both of these provided you with a type (e.g. Pilot) at compile time. If you don't know the type at compile time, you can use the DB4O SODA query instead:
var query = db.Query(); query.Constrain(someObj.GetType()); var results = query.Execute();
edit Why use LINQ instead of SODA, Query-by-Example (QBE) or Native Query (NQ)? Because LINQ makes it very natural to execute query expressions. For example, here, as you request pilots named Michael:
var michaelPilots = from Pilot p in db where p.Name == "Michael" select p;
And LINQ is composite, that is, you can do things like this:
var first20MichaelPilots = michaelPilots.Take(20);
And you still get an efficient query executed in DB4O when you iterate over the results. Doing the same in SODA or QBE or NQ is ugly at best.