Skip to main content
2 of 4
added 65 characters in body
Arie
  • 149
  • 5

Repository pattern usage

I need some advice regarding repository pattern. Let's assume i have UserBal which stands for business logic which uses UserRepositoryDal where all database logic for that entity stands (queries to table T_Users) Keep in mind at the moment my repositories uses stored procedures. In my database i have table T_Users. There is also table T_UserTypes. In T_User table there is relation to T_UserTypes so means every user has his own user type. In my applciation i've created:

UserBal - for business logic and uses UserRepositoryDal
UserRepositoryDal - all database logic to get data for 'T_Users'

Repository have common functionality like: GetAll(), Insert etc..

My entites are:

public class User
{
     public int Id { get; set; }
     public string Name{ get; set; }
     public int FK_UserType { get; set; }
}

public class UserType
{
     public int Id { get; set; }
     public string Name{ get; set; }
}

I am not sure at this point whether should i create also repository for table T_UserTypes like: UserTypeRepositoryDal and for business logic UserTypeBal which would use UserTypeRepositoryDal ?

or should i just modify my User class instead of:

public int FK_UserType { get; set; } 

change to:

public UserType UserType { get; set; }

so there would not be UserTypeBal and UserTypeRepositoryDal at all

Nevertheless when in application i would like to get list of UserType for instance for combobox control or whatever i would not have UserTypeRepositoryDal with GetAll() so where should i put logic for UserTypes GetAll(). Should it be in UserRepositoryDal?

If something unclear let me know. Thanks for answers.

Arie
  • 149
  • 5