What is NSprocs?
In short, NSprocs is a code generator that creates glue code between database stored procedures and your .NET code. Normally, to call a stored procedure from .NET, you'd need to create and open a connection, construct a command, fill out parameters, and finally run the command. NSprocs generates this code for you, so that calling any stored procedure in your database can be done with a single line of code.
It's worth noting that NSprocs is not an ORM layer; NSprocs-generated methods cannot return anything more structured than a dataset.
Why use NSprocs?
NSprocs provides three key benefits:
- Productivity. Write way less ADO.NET code. Period. Write your new stored proc, and be using it in .NET with a single click.
- Conformance. NSprocs calls each procedure in exactly the same way, and leaves room for you to add logging, instrumentation, and error trapping as part of each method call. You can implement ADO.NET best practices in one place, and be sure that all database code in your application is taking advantage of that.
- Confidence. C# is a strongly typed language, which lets the compiler detect all sorts of buggy code at compile time instead of at runtime, where only tedious debugging can solve the problem. But when you use ADO.NET to invoke stored procedures, the compiler has no idea whether the parameters your code sends are what the procedure expects, or whether the procedure even exists anymore. NSprocs solves this problem by wrapping each stored procedure in a method whose signature closely matches that of the original stored procedure. This means that if you change the procedure's parameters or name, you'll get actual C# compiler errors! This can be enormously beneficial in small to medium sized teams in which each developer is also a cowboy DBA.
Who is NSprocs for?
For Microsoft Visual Studio.NET 2005 developers building applications that must access their database through stored procedures, or would like to.
How do I use NSprocs?
Start off by writing your stored procedures. Use just about any SQL Server data as a parameter, including GUIDs and BLOBs.
In your Visual Studio 2005 project, add a simple xml configuration file. You'll describe where to find your database, and how the code will be generated. Don't worry, because there's an extensively self-documented example file to get you started.
Once you're satisfied with the configuration file, pull up the properties tab in Visual Studio and set the Custom Tool to NSprocs. There may be a slight pause while your code is generated.
You're done! Start coding using your new auto-generated class. You'll get code completion and IntelliSense parameters for all your stored procedures.