title: How to organize Data Access Layer (DAL) in ASP.NET
body: <p>I have an ASP.NET Web Forms application developed in C#. </p>
  
  <p>I would like to give structure my application by <strong>separating the DAL tasks from the code behind.</strong></p>
  
  <p>I created a class in App_Code, <strong>DBUtilities</strong> that takes care of the communication with the database, in order not to have duplicated code all along the application. The class has methods to get datatables, scalar values, etc... and they accept as parameters the <strong>connection string name</strong> and the <strong>query command</strong> as string. </p>
  
  <p>The problem is that I have still all the queries' commands in my code behind. Many of them are duplicated all around the pages and this cause maintanance problems. </p>
  
  <p>I was wondering if it is a good practice to create a (static) class <strong>QueryRepository</strong> that contains many <strong>string properties</strong> and associate to each of them a specific query command. Everytime I want to execute the query command <strong>MyCommand</strong> I pass to the <strong>DBUtilities</strong> class the <code>QueryRepository.MyCommand</code> property instaed of the string. Morevoer if I need to change a query command I do it just on the QueryRepository class.</p>
  
  <p>Is it a good way to organize my DAL?  </p>