Click here to Skip to main content
15,891,529 members
Articles / Database Development / SQL Server

Template based code generation

Rate me:
Please Sign up or sign in to vote.
4.48/5 (10 votes)
10 Mar 2005CPOL9 min read 70.6K   1.6K   56  
An article about template based code generation and a demonstration of how to quickly generate a wrapper class for stored procedures.
using System;
using NUnit.Framework;
using DatabaseCatalogReader;

namespace DatabaseCatalogReader.Test
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	[TestFixture]
	public class Class1
	{
		public Class1()
		{
			//
			// TODO: Add constructor logic here
			//
		}

        [Test]
        public void RunTest()
        {
            DatabaseCatalog cat = new DatabaseCatalog();
            Console.WriteLine("Database Name: {0}", cat.Name);

            foreach(SqlStoredProcedure proc in cat.GetStoredProcedures())
            {
                Console.WriteLine("  Proc Name: {0}", proc.Name);
                foreach(ProcParameter p in proc.GetParameters())
                    Console.WriteLine("    {0} {1} {2} {3} {4}",
                        p.Name,
                        p.Ordinal,
                        p.Type,
                        p.Length,
                        p.Direction);
            }
        }
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
I am a consultant, trainer, software archtect/engineer, since the early 1980s, working in the greater area of Boston, MA, USA.

My work comprises the entire spectrum of software, shrink-wrapped applications, IT client-server, systems and protocol related work, compilers and operating systems, and more ....

I am currently focused on platform development for distributed computing in service oriented data centers.

Comments and Discussions