Why are functions considered differently than sprocs?
Copied from LLBLGenPro Help - Using the generated code - Calling a database function:
On some databases, the difference between a stored procedure and a function is non-existent. The database function meant here is a function which is either a system function, like GETDATE() on SqlServer, or a user defined function in a schema and is not directly callable from the outside through ADO.NET unless a special crafted SQL statement is used. Rule of thumb: if you need an explicit EXEC statement to execute the function, it's not callable by this mechanism: the function has to be callable from within a SELECT statement for example.
Also, I think that could be very inappropriate to include in the framework a wrapper call for every SQL_DBFuntion
Also, the docs have a very obscure example.
I see everything clear: The DBFuntcion creation and DBFunction call. What do you mean about obscure?
I just want to see how to call a simple function and the docs go into dynamic list stuff.
Well, you can do a very simple call
:
object thisYear = adapter.GetScalar(CustomersFields.Address.SetExpression(
new DbFunctionCall("YEAR", new object[] { DateTime.Now })), AggregateFunction.None);
However, in most cases, we might include the Function in a resulset (dynamic list, typed list, etc.).
The docs don't show how the actual call is made to fn_CalculateOrderTotal.fields[3].ExpressionToApply = new Expression( new DbFunctionCall( "YEAR", new object[] { OrderFields.OrderDate } ), ExOp.Add, 4 );
You can see the SQL generated for the call. Please refer to LLBLGenProHelp - Generated code - Troubleshooting and debugging
You can do very simple and also powerful things with DBFunctionCalls