Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8025721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:15:24+00:00 2026-06-04T23:15:24+00:00

Supposing a classic 3 tier application. In DAL, you have a GenericRepository where T

  • 0

Supposing a classic 3 tier application. In DAL, you have a GenericRepository where T represent your POCO class and it include some method like Insert(T entity), Delete(T entity), Update(T entity) and so on. Then, your BLL (business logic class) contains something like CustomerRepositor.
Well, all rights.

Now, image your aspx page:

var customers = BLL.CustomerRepository.GetAll();
customers.First().Name = "some name"; 

Not good, you have to pass by CustomerRepository.Update, Insert or Delete methods in order to I can execute some validation for all CRUD operations. In this way all business logic will not works as I aspected.

I note that no-one has never thought about this, but I think is an important question. has not make sense to have business method for CRUD operation if yuo can bypass them.

Am I missing something?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:15:27+00:00Added an answer on June 4, 2026 at 11:15 pm

    Well, lets start.

    var customers = BLL.CustomerRepository.GetAll();
    

    This was a nice line of code in the last millenium. Before generics and LINQ came along. Seirously.

    These days, I would expect it at least to be like this:

    var customers = BLL.Repository<Customer>.ToList (); //IF you have to materialize
    

    There is no need for an “All” method at all 😉

    Am I missing something?

    To a large degree an understanding that you are still within an application, so compromises are sort of acceptable. It is not like you run a trust boundary between applications here. Second, the fact that you should have programmed a better abstraction.

    Repository repository = BLL.GetRepository ();
    var customer s repository.Entity<Customer>.ToList ();
    customer[0].Name = null;
    repository.ValidateU ();
    repository.Commit ();
    

    would be a lot better abstraction. Creation is not done with “new” but with

    var newCustomer = repository.Create<Customer> ();
    

    which then commits.

    All validation can be checked in the Validate method.

    At the end, this is about HOW you design your interface for the repository – and if you insist on not keeping any state (which is a valid pattern for some operations) then this opens you to problems. And yes, you can have repositories that do not do full validation – totally valid. It really depends. You may be surprised, but I work on applications mostly where the repository is often not even updated in the same transaction as the object for performance reasons, and updates are queued and then batched, while the in memory version is the relevant one for all further operations.

    It shows, at the end, that a little more thinking about how to design the DAL interface is in order, and please please please stop using an approach that is totally outdated and just leads to method creep (as you need tons of methods that otherwise just disappear in generics + linq expression trees.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Supposing to have something like this: #include <map> int main(){ std::map<int,int> m; m[1] =
Supposing I mark a method @Transactional(rollbackFor = PersistenceException.class) in my Service layer and have
Supposing I have some random block of text in a single line. Like so
Supposing I have a StringerHelper(Component|Helper|Behaviour).php class with a method for random strings. I might
Supposing I have a 2 dimensional array which was created with something like this,
Supposing I've got multiple div's with the same class, I could do something like
We've got a classic ASP application that is putting out some very large reports,
Supposing I have the following: module A class B # ... end # ...
Supposing I have the following public class Foo { private Map<Integer,SomeObject> myMap; public Foo()
Supposing I have a list/tuple like this: MyLocation = 'DE' ( ('Pencils', 'Artists Pencils',

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.