Data quering from asp.net custom control

43 views Asked by At

Could you tell me if it is a correct way to query data from custom control directly. For example I'm implementing control that query data via business services from database. This let me avoid code duplication like

ctrl.DataSource = BusinessService.GetRequiedData();
ctrl.DataBind();

What do you think? Is it merging of presentation and application layers? Should I avoid to use such data querying?

1

There are 1 answers

0
Adam Heeg On

In my opinion that appears just fine. You're going to have to connect to some other layer, so the question is, do you need to separate your BusinessService layer from your presentation? The only answers I can think of are if you need to add a layer of security, or if you need to abstract out domain types to make your calls platform independent (like if your business layer is tied to Entity Framework or another technology - which it shouldn't be).

I think you are fine.