CodeFluent Query Language (a.k.a. CFQL) allows you to write platform independent data accessing queries which producers (producer = code generator) will translate into optimized stored procedures.
For instance you can define the following CFQL query in your model:
<cf:method name="LoadByName" body="load(Name) where Name startswith @Name"/>
The SQL Server Producer will generate the following stored procedure:
CREATE PROCEDURE [dbo].[Test_LoadByName] ( @Name [nvarchar] (256) ) AS SET NOCOUNT ON SELECT DISTINCT [Test].[Test_Id], [Test].[Test_Name] FROM [Test] WHERE ([Test].[Test_Name] LIKE (@Name + '%')) RETURN
And the Oracle Database Producer will generate the following equivalent:
PROCEDURE LoadByName(CF_CURSOR OUT "Sample"."CF_#Runtime".CF_CURSOR_TYPE, "#Name" NVARCHAR2) AS V_CF_CURSOR "Sample"."CF_#Runtime".CF_CURSOR_TYPE; BEGIN OPEN V_CF_CURSOR FOR SELECT "Test"."Test_Id", "Test"."Test_Name" FROM "Sample"."Test" WHERE ("Test"."Test_Name" LIKE ("#Name" || N'%')); CF_CURSOR := V_CF_CURSOR; END;
As you can see data accessing queries are not built in-memory dynamically at run time but instead a classic stored procedure is generated at development time.
As a consequence developers can:
- see what’s going to happen at run time and avoid bad surprises (like this one when using EF for instance),
- debug it easily if they need to,
- change the code if the need to.
Cheers,
Carl Anderson
