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 because my repositories uses stored procedures.) In my database i have table T_Users
. There is also table and T_UserTypes
. In T_User
table there is relation to T_UserTypes
so. It means everyeach user has his own user type.
In my applciationapplication i've created:
UserBal - for business logic and uses UserRepositoryDal
UserRepositoryDal - all database logic to get data for 'T_Users'
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 comboboxcombo box 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.