#1 2011-12-07 08:52:33

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,682
Website

Automatic JOIN query

In mORMot, all the methods available to handle many-to-many relationship (ManySelect, DestGetJoined...) are used to retrieve the relations between tables from the pivot table point of view. This saves bandwidth, and can be used in most simple cases, but it is not the only way to perform requests on many-to-many relationships. And you may have several TSQLRecordMany instances in the same main record - in this case, those methods won't help you.

A JOIN is a means for combining fields from two or more tables by using values common to each. Writing such JOINed statements is not so easy by hand, especially because you'll have to work with several tables, and have to specify the exact fields to be retrieved; if you have several pivot tables, it may start to be a nightmare.

With this source code enhancement, our ORM will make all the dirty work for you! You can use Delphi-level conditions in your query, and the engine will transparently convert them into a valid SQL statement. Benefit of this will become clear in case of multiple pivot tables, which are likely to occur in real-world applications.

See http://blog.synopse.info/post/2011/12/0 … JOIN-query
and http://synopse.info/forum/viewtopic.php?pid=3185#p3185

Offline

Board footer

Powered by FluxBB