Question

Is there any way to call table-valued UDF with Dapper, except:

var rows = connection.Query("select * from My_UDF(@a,@b)", new {a=1, b=2 });

I prefer to avoid magic strings hence I would like to use something similar to calling SP syntax.

I use MS SQL Server 2008 R2.

Accepted Answer

No. Dapper basically (with a few tweaks) follows the same rules as ADO.NET, and in both ADO.NET and raw TSQL, what you have posted is the only way of invoking a UDF - therefore, that remains the syntax used by dapper. Additionally, when calling a UDF you are required to specify the schema-name (typically dbo.My_UDF).




Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why