I use C# Entity Framework and Asp.net Web Forms 4.
At the moment I'm developing the Administrator section for a Cms so I have to work with many GridView Controls for CRUD operations on my data.
I use EF as DAL and I implement my Business Logic inside every .aspx page; Pages are organized logically by folders.
My BL are pretty simple like: for User A takes from DB X, Y, Z and display it on a GridView instead for User B takes from DB only X and display on the same GridView.
In my little experience I found my self spending a lot of time in embedding my BL Roles inside each .aspx using Event Triggers Web Form Mechanism. My problem is that same pages could have the same BL and so I have to copy and paste my code in may different .aspx pages.
My questions:
Thanks for your time on this!
You need to layer your application - for example, in a typical scenario, you can have following projects:
You are already made choice of EF4 as your DAL. You may use POCO entities (Code-First model) to have your entity/DTO classes in a separate project. As far as your business logic goes, put that in business layer which is actually bunch of classes that would define API. For example,
public static class CustomerHelper
{
public static Customer Get(int customerId)
{
// do access control security
...
// use EF4 to get the customer object
}
public static void Update(Customer customer)
{
// do access control security
...
// use EF4 to update the customer object
}
}
Generally, business layer can have validations, security checks, transaction control, any pre/post processing needed for the business transaction etc.
Finally, your aspx pages will be your UI layer that would use BL classes to get/update the data. For declarative data-binding, you have to use object data source.