Using a SQL scalar-valued function in a query

Dec 19, 2014 at 12:20 PM
I'm trying to us a scalar-valued function in my Product repository.
In the SQL Management Studio, you can find these functions under the node Databasename -> Programmability -> Functions -> Scalar-valued functions

This scalar-valued function does a lot of background calculation on different tables in the database just to get a custom nettoprice for a specific customer.

I know how to call a stored procedure in this generic framework but I actually want to make the function a part of the select fields in the query.

So how can I implement the following query:
SELECT ProductNr, db.TSqlGetNettoPriceForCustomer(iCustomer), ProductName,... FROM Product...

where db is my DbContext

Any help would be greatly appreciated,
Dec 20, 2014 at 1:50 AM
Out of the box, the framework does not handle this. Recommendation here is to create a wrapper SPROC that will do your select statement with your TSqlGetNettoPriceForCustomer in it and call this from the framework with stored procs.
Marked as answer by lelong37 on 12/19/2014 at 5:50 PM