Native Query Implementation

So how are Native Queries realized in practice?

Let's return to the Pilot class. Suppose we need to find all pilots with the name starting from "M" and points over 100. In a native OO language it would be expressed as:

c#: 

pilot.Name.StartsWith("M") && pilot.Points > 100

In order to pass this condition to a database, collection or other query processor a special object is used. In .NET2 it is a delegate, in Java5 it is a named method.

c#: 

delegate(Pilot pilot){

    return pilot.Name.StartsWith("M")&& student.Points > 100;

}

 

For more information about NQ implementations in the other Java and .NET versions see Native Query Syntax.