Search code examples
asp.netentity-frameworklinq-to-sqldevforce

ASP.NET 4 SQL Methods?


Currently working on an ASP.NET web app and am starting to realise i'm writing the same Boiler Plate Code Over and Over Again..

i.e.

        SqlDataReader myReader = null;
        SqlCommand SQLcmd = new SqlCommand();
        SqlConnection SQLConn = new SqlConnection();
        String SQLStatement = "Select this 'nd That";
        SQLConn.ConnectionString = SQLConnectionString;
        SQLConn.Open();
        SQLcmd.Connection = SQLConn;
        SQLcmd.CommandText = SQLStatement;
        myReader = SQLcmd.ExecuteReader();
        while (myReader.Read())
        {
            //Do some awesome
        }
        SQLConn.Close();
    }

How is the .NET world playing with SQL now?

Basically how can i not spend half the day copying and pasting that code?

Is everyone using Linq to SQL? and if so please point me to a tutorial!

Thanks a lot!

Daniel


Solution

  • The general mood these days is to use some sort of ORM.

    Popular choices are:

    Linq2Sql is indeed an ORM, but it is no longer being actively developed within Microsoft.