Archive for August, 2011

Meet us at Visual Studio Live – Redmond

August 22, 2011 Leave a comment

Arguments in CFQL

August 19, 2011 Leave a comment

CFQL methods can take arguments. Arguments in CFQL are composed of an optional type name and a name.

If the type name isn’t specified CodeFluent Entities looks for a property in the current entity matching the argument name.

For instance, instead of writing:

  <Id />
  <Code />
  <Price />
  <cf:method name="LoadByCode" body="load(string code) where Code = @code" />

You can write:

<cf:method name="LoadByCode" body="load(Code) where Code = @Code" />

Note: CFQL is case insensitive, writing “Code” or “code” or “LOAD” or “load” doesn’t matter.

This actually allows you to write flexible models: since if you change the property type, you won’t have to update your methods.

Keeping the same concern in mind, you can write expressions using entity names instead of their keys, such as:

<cf:method name=”LoadByRole” body=”load(Role Role) where Role = @Role” />

This should be preferred to writing methods such as this one:

<cf:method name=”LoadByRole” body=”load(guid roleId) where Role.Id = @roleId” />

The result will indeed be the same, however, if you change the type of the Role identifier, or if you update the Role entity to have a composite key your code will break. To the contrary, using the first method using the “Role = @Role” statement will keep on working.

CodeFluent Query Language Overview

August 18, 2011 3 comments

CodeFluent Query Language (CFQL) is a simple yet powerful language which allows developers to write stored procedures in their models. Therefore, CFQL is platform independent and its producers which will translate this query into an actual stored procedure.

The language itself is a mix of traditional SQL and object-oriented syntaxes (btw, the language is case insensitive):

<method> (<arguments>) [from <source>] [<where> <expression>] [<order by> <expression>]

Available methods are:

  • Load / loadone: creates a procedure to return one or multiple instances from the database,
  • Search: similar to load methods, however arguments are optional/nullable, supports wildcards (e.g. ‘*’), and the resulting SQL is built dynamically at run time in order to support as many optional parameters as you desire,
  • Count: return a number being the result of the count operation (uses the count SQL clause),
  • Delete: allows developers to delete batches of records from the persistence layer (and avoid doing deletes in a foreach)
  • Raw: allows developers to specify custom persistence code because CFQL does not intend to replace persistence code, so you can’t do everything with it.

Modeler Hot Keys

August 17, 2011 1 comment

Using the Modeler, a graphic interface to CodeFluent Entities integrated to Visual Studio 2008 & 2010, several hot keys are available to ease developers’ life while designing their model.


CTRL + Click on a relation property

Clicking on a relation property whilst holding the CTRL key down zooms on the referenced entity and surrounds it with an animated red square so you can easily spot it:


SHIFT + Click on a property

Clicking on a property whilst holding the SHIFT key down allows you to create relations. Holding SHIFT while selecting a property makes an arrow appear which you can use to point to another property or entity.

Once you pointed to the referenced entity/property, the “Add New Relation” dialog will appear so you can define the relation’s multiplicity (One-To-One, One-To-Many, Many-To-One, Many-To-Many)


CTRL + Scrolling with the mouse wheel

Holding the CTRL key and scrolling with the mouse wheel lets you zoom in or out where the mouse points. It’s dead simple, yet so convenient!


CTRL + Dragging anywhere on the surface

Doing so allows you to zoom in a specific area. CTRL + dragging will make a dashed rectangle appear symbolizing the area in which the Modeler should zoom in:

Converting an existing CodeFluent Entities project to the new Visual Studio CodeFluent Entities format (.cfxproj) –Part 2

August 16, 2011 Leave a comment

In a previous post we introduced how to convert a former CodeFluent Entities project into a Modeler one. What is said in this previous post is still valid, nevertheless, a quick update can be done as the convert form is now directly included in Visual Studio.

  • Start Visual Studio, and go in File > Project > New…
  • Select CodeFluent Entities, and the Legacy Model template,


  • Make the Package Path point to your source model
  • Set your project path to the Target Directory Path and hit Next.



And that’s it your done! A new cfxproj was created and opened in Visual Studio.

Using the Property Grid in a CodeFluent Entities Project

August 12, 2011 1 comment

All Visual Studio developers are familiar with the Property Grid which allows developers to view and edit all properties of the currently selected object.

The Modeler provides its own, available when editing a Surface or the XML, and which is organized into three views:

  1. Default view
  2. Advanced view
  3. Aspects and Producers view

You can switch from one view to another using their corresponding button available at the very top of the property grid.


The Default View

In the default you’ll find all “common” properties, those most frequently used.



The Advanced View

The advanced view provides access to all other properties. Properties available in this view are optional and provide extra features you can set on the currently selected element.



The Aspects And Producers View

Finally, this view allows developers to access extra-properties brought by aspects and producers which were added to the project.


Meet us at DevConnections Las Vegas

August 11, 2011 Leave a comment