.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Is there a better way to do this

Posted By:      Posted Date: October 01, 2010    Points: 0   Category :ASP.Net

Good afternoon Ladies and Gents,

In my neverending quest to do things the best that I can, I come to you for suggestions. I recently have come into a situation that required me to use SQL stored procedures in my C# applications. I had been using LINQ to SQL and EF previously and had no experience with stored procedures. Embracing the SPROC methods but also providing same compatibility and object modeling as LINQ/EF I came up with the following class. I want to know how I can improve it.

Usage w/o parameters:

List<GenericClass> list = new StoredProcedureModel(_sqlConn, "ProcedureName").ToList<GenericClass>(); 

With parameters:

StoredProcedureModel spm = new StoredProcedureModel(sqlConnectionString, procedureName);
List<GenericClass> list = spm.ToList<GenericClass>();


using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Reflection;

/// <summary>
/// Class to project SQL stored procedures into a strongly typed generic list. 
/// The SQL column names must match the generic's parameters. Parameters that
/// don't match

View Complete Post

More Related Resource Links

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend