Data Access Layer and Business Objects

Not sure if I have the right terminology, but I'm a little confused about how to set up my three-tier system.

Suppose I have a user table in my database.

In my DAL, I have a UserDB class that calls stored procs in its DB to insert, update, delete. I also have a UserDetails class that is used in UserDB to return and pass objects.

So now I'm not sure how to use this in my business logic layer. Do I need another class of BLL objects for users? If so, would that be superfluous? Or am I just using the UserDetails class throughout my BLL?

+5
source share
3 answers

"Domain Driven Design" - , (, UserDB) , factory. - - -.

? - ActiveRecord, , .

+3

BLL. , call- 10% , 20% . - BLL, :

// Pseodocode
double Discount
{
    set
    {
        if (value > 10% AND Employee Is Not Manager) then throw Exception
        if (value > 20%) then throw Exception
        discount = value;
    }
}
+2

:

DAL:

namespace DAL.Repository
{
    public class UsersRepository
    {
        public static IList GetUser(string UserId)
        { 
            using(MyDBEntities context=new MyDBEntities())
            {
               // it calls SP in DB thru EF to fetch data
               //here you can also context.user to fetch data instead of SP
                return context.GetUser(UserId).ToList();

            }
        }
    }
}
BLL

namespace BLL
{
   public class User
    {
       public static IList GetUser(string UserId)
       {
           return DAL.Repository.UserRepository.GetUser(UserId);
       }
    }
}
PL

  ddlUser.DataTextField = "UserName";
  ddlUser.DataValueField = "UserId";
  ddlUser.DataSource= BLL.User.GetUser(string.Empty);
  ddlUser.DataBind()

: BL PL DB Entity - , PL.

0
source

All Articles