Login Skip Navigation LinksWilsonORMapper > Forums Search
Demo Version Demo Version
Download and try for yourself a fully working demo version, including sample apps and documentation.  The only limitation is that the demo version only works inside the debugger.

PayPal Subscribe
Get It All for $50 USD:
WebPortal, ORMapper,
Source Code, All Updates
PayPal

User Login User Login
Log In
 
 
Reset Password

Wilson ORMapper Forums Wilson ORMapper Forums : OPath Queries : Advanced query

Date Post
6/14/2006 12:25:11 PM Hi,

I'm trying to achieve the following data layout:

http://perryworld.co.uk/testarea/sample.gif

and was wondering if I can get the data from the db using opath. The data is a parent/child self referencing table with Spain being the parent and then 3 child areas beneath it. Next to each parent/child I need to display a count of the number of child items.

Can the WORM help with this?

Many Thanks
Kieran
6/16/2006 3:45:05 AM

The short answer is:  Not in one query/call to the database.  The OPath engine currently does not have support for aggregates, so that is the first problem you would run into.  The self-referencing part is probably something OPath can handle; queries can traverse into themselves so long as the mapping file has the relationship setup correctly.

 

If you did what to you OPath (and you should seriously consider a stored procedure or the like first), you could query for your parent objects, then query each child to get the counts.  This would not be at all efficient because you would have to return (and convert to objects) all the records you are counting, just to get the count, but sometimes it's worth the tradeoff to keep from hitting the DB directly with database-specific queries (or it such a small dataset it doesn't matter what you do).

 

- Jeff Lanning