This is a complex query using a lot of server-side functions and querying from two tables without a join specified and then joining with a third table. It is not possible to generate similar query using OQL as most of the SQL functions you are using are not available via OQL. There is however, another approach which I find more straight-forward and easier to implement. This query, looks like the perfect candidate for a database View, which you can create on your server. OpenAccess is able to map views to entities so you would get an object with the name of the view and you can easily query that using the IObjectScope. So imagine your view is called "CustomView":
IObjectScope scope = OpenAccessData.ObjectScopeProvider1.GetNewObjectScope();
"SELECT customView FROM CustomViewExtent AS customView"
var result = scope.GetOqlQuery(query).Execute();
//do something with the CustomView objects returned.
The code above will execute the exact same query you have in the database and materialize it to an appropriate object.
the Telerik team
Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!