Arguments in CFQL
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:
<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.