title: What is the best approach when creating data access objects?
body: <p>I have a method in MyWebpage.aspx.cs lik so:</p>
  
  <pre><code>public partial class MyWebpage : PageBase
  {
      private readonly DataAccessLayer dataAccessLayer;
  
      protected string GetMyTitle(string myVar, string myId)
      {
          if (string.IsNullOrEmpty(myVar))
          {
              return string.Empty;
          }
  
          return dataAccessLayer.GetMyTitle(Convert.ToInt32(myId), myVar);
      }
  }
  </code></pre>
  
  <p>In the DataAccessLayer class, I have a methoud that talks to the DB and does the DAL stuff and returns the title.</p>
  
  <p>What's the best practice on accessing the DAL from MyWebPage.aspx.cs class (as in do I need to create a new DataAccessLayer() object each time? Where should I create it in my PageBase class or everytime I call it in a code behind?</p>