I just ran some basic tests against the Profiler and gathered some interesting results.
1. Inserting a record into a table via standard T-SQL: (via Management Studio)
INSERT INTO Contribution VALUES(450,'4/4/2005',1)
2. Insert a record via a CLR Stored Procedure that uses LLBLGen classes.
The following class was compiled into a class library and loaded into SQL Server 2005. It uses a modified version of ORMSupportClasses.dll, with many framework dependencies removed. (SQL Server only has access to a limited subset of the framework)
public class StoredProcedures
{
[SqlProcedure]
public static int InsertContribution(SqlInt32 contactID, SqlDecimal amount, SqlDateTime datetime)
{
// Do null check
if (contactID.IsNull || amount.IsNull || datetime.IsNull)
return -1;
// Do insert
RulesEngine.HelperClasses.DbUtils.ActualConnectionString = "context connection=true";
RulesEngine.EntityClasses.ContributionEntity ce = new RulesEngine.EntityClasses.ContributionEntity();
ce.ContactId = contactID.Value;
ce.Amount = amount.Value;
ce.Date = datetime.Value;
bool success = ce.Save();
return success ? 0 : -1;
}
}
This stored procedure was executed via T-SQL as
EXEC dbo.InsertContribution 1,123,'6/6/2005'
3. Insert a contribution via a test client running the same LLBLGen generated DAL assembly to call the CLR stored procedure.
Code to run this simple command line app:
namespace TestClient
{
class Program
{
static void Main(string[] args)
{
RulesEngine.StoredProcedureCallerClasses.ActionProcedures.InsertContribution(1, 650, DateTime.Now);
}
}
}
The difference in duration between these three tests is negligible.
Granted, this was done in a controlled, local instance, with no load, but it looks very promising for .NET coders who want to put logic into SQL Server. Especially considering they can use LLBLGen classes with no performance penalty! (at first glance).