No RowSets, DataSets, or such Things - Only Objects
  • Linq-Queries
  • SQL-like query language to formulate query conditions
  • Optional SQL queries

You do not work with row sets or similar database-centric things in NDO, but with .NET container classes such as List<T> that contain the requested objects. A query is made as follows:

var allEmployees = persistenceManager.Objects<Employee>();

Objects<Employee> is a virtual table that triggers an SQL query when assigning the virtual table to a result variable, for example in a foreach statement.

The virtual tables can be queried with Linq:

from m in persistenceManager.Objects<Employee>() where m.Salary > 50000 select m; 


from m in allEmployees where m.Salary > 50000 select m;

Salary is a so-called accessor property, whose getter returns a private field of the Employee class. NDO stores and maps these private fields.

The following query is somewhat more complex:

var result = from c in persistenceManager.Objects<Customer> where c.Orders.OrderItems.Product.Name == "Shirt" select c;

This generates the following SQL query:

SELECT Customer.* FROM Customer 
INNER JOIN Orders ON Orders.IDCustomer = Customer.ID
INNER JOIN OrderItem ON OrderItem.IDBestellung = Orders.ID
INNER JOIN Product ON Product.ID = OrderItem.IDProduct
WHERE Product.Name = 'Shirt'

In more complicated situations, you can also query SQL directly. As long as these queries generate rows that match the column information in the mapping file, NDO automatically generates objects from those rows:

NDOQuery<Employee> q = new NDOQuery<Employee>(pm, "SELECT * FROM Employees WHERE Salary > 50000", false, Query.Language.Sql);
List<Employee> l = q.Execute(); // l contains Employee objects


-> Vererbung und Polymorphie