From a CLR UDF (C# syntax) is it possible to acquire a more or less direct handle to a built-in TSql function, instead of trying to kludge it into an ADO.NET SQL text like so?
// Programming .inside NET CLR UDF:
// Is there a more efficient way than this command?
SqlCommand cmd... = new SqlCommand( ...'SELECT EncryptByKey(@Param, @Param2...) );
cmd.Execute();
The above textual SQL way seems inefficient if the method is being run multiple times. I suppose it would depend on the SQL Server integration features available in the .NET Framework Class Library when creating the UDF.
Maybe this is already the most efficient means available considering the APIs. I don't know.
Using SQL Server 2005.
Example of Built-in
An example of a built-in function I've been using and this can serve as the example, is SQL Server's EncryptByKey(..) function.
Encryption is called multiple times on many values and fields in a secure database. When it's used it's often highly used, unlike some other functions that are just called sporadically.
It cannot be called like a custom UDF with dbo because it's not owned, it's part of SQL Server.
select dbo.EncryptByKey(..)
<< SQL
Server error
Instead it must be called unqualified like so
select EncryptByKey(..)
. << OK
It would be nice to call this more efficiently when it's used in a CLR UDF like above, considering its usage is so prevalent and constant.