Relations in Queries
In the travel expense accounting example there is a 1:n relationship between the Employee and the Travel classes.
[NDOPersistent]
class Employee
{
[NDORelation(typeof(Travel))]
IList travels;
...
}
Now Suppose you want to find all employees who traveled with the purpose "TechEd 2006". The NDOql query for this is
travels.Purpose LIKE 'TechEd 2006'
which is converted to the following SQL query
SELECT Employee.* FROM Employee, Travels
WHERE Travels.Purpose LIKE 'TechEd 2006'
AND Employee.IDemployee = Employee.ID
As you can see you don’t have to bother with Join-queries in NDOql.
The keyword OID allows to specify Id-columns as names in query expressions:
ObjectId oid = SomeObject.NDOObjectId;
...
Query q = pm.NewQuery(typeof (Employee), "OID = {0}");
q.Parameters.Add(oid.Id.Value);