Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting up a proper nTier application
    text
    copied!<p>While I know there are many ways of doing this, I'm just wondering if this is <em>way</em> off base. </p> <p>I have a solution that has three DLL's, UI (asp.net web application), Business layer, and DAL. So my code mainly looks like this (very raw example code): </p> <p>UI</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { Beanpole.Business.Project myProject = new Beanpole.Business.Project(); myProject.LoadProject(Convert.ToInt32(Request["id"].ToString())); Response.Write(myProject.ProjectName + "&lt;br&gt;" + myProject.ProjectDescription); } </code></pre> <p>BLL</p> <pre><code>using ... using Business.Providers; namespace Business { public class Project { public string ProjectName { get; set; } public string ProjectDescription { get; set; } public bool LoadProject(int projectId) { DataTable dt = DBProvider.Instance().LoadProject(projectId).Tables[0]; if (dt.Rows.Count == 0) return false; LoadProjectFromRow(dt.Rows[0]); return true; } internal void LoadProjectFromRow(DataRow row) { this.ProjectName = (string)row["Name"]; this.ProjectDescription = (string)row["Description"]; } } } </code></pre> <p>Data provider (Business dll)</p> <pre><code>namespace Business.Providers { public class DBProvider { private static IDataAccess _getDataAccessComponent = null; public static IDataAccess Instance() { if (_getDataAccessComponent == null) { const string className = "My.Data.DataAccess, My.Data"; _getDataAccessComponent = (IDataAccess)Activator.CreateInstance(Type.GetType(className)); } return _getDataAccessComponent; } } } </code></pre> <p>DAL Interface</p> <pre><code>namespace My.Data { public interface IDataAccess { DataSet LoadProject(int projectId); } } </code></pre> <p>Data access </p> <pre><code>namespace My.Data { public class DataAccess : IDataAccess { public DataSet LoadProject(int projectId) { SqlParameter[] _params = new SqlParameter[1]; _params[0] = new SqlParameter("@ProjectId", SqlDbType.Int) { Value = projectId }; return SqlHelper.ExecuteDataset(connString, "up_LoadProject", _params); } } } </code></pre> <p>The main issue I have with this set up is the <code>DBProvider</code> class. It bothers me for some reason and I just can't seem to figure out why, or shake it and keep going. It's almost like it's causing my writers block. I have this same pattern working very well in another application and all is good, but it seems like a lot of extra code for no gain. </p> <p>Any tips would be helpful. </p> <p>Also I'm working on 3.5 right now, but thinking of moving to 4.0 once I can get VS 2010. </p> <p>Edit: Just picked up VS 2010 over the weekend, so I'm moving the app over to 4.0 in hopes of better EF or LINQ to SQL support. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload