Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should my DAL return Person or Datatable?

After reading this , I still have a question :

I use this code to query the db :

c# :

new BLL().GetPersonById(1)

BLL :

public Person GetPersonById(int id)
{
  return new DAL ().GetPersonById(1);
}

DAL :

public Person  GetPersonById(int id)
{
   // goto db and create instance of Person and fill its data...
}

However , am I doing it wrong ,

Should my DAL return DataTable instead ? ( so the BLL will create Person .... ?)

DAL :

public DataTable  GetPersonById(int id)
{
   // goto db ...
}

Thank you.

Edit :

the Person object is defined in BE dll ( business entity).

like image 914
Royi Namir Avatar asked Nov 15 '25 20:11

Royi Namir


1 Answers

"Should my DAL return DataTable instead ? ( so the BLL will create Person .... ?)"

Not at all. Ideally DAL is supposed to deal with database and should return entity/application objects to BAL. DAL works as a abstraction for database to BLL.

And I am agree with MikeSW as he said "BLL shouldn't depend on the DAL, at most it defines some interfaces which will be implemented in the DAL."

like image 144
Praveen Prajapati Avatar answered Nov 17 '25 12:11

Praveen Prajapati



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!