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

  • SEARCH
  • Home
  • 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 7610385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:24:21+00:00 2026-05-31T01:24:21+00:00

I try to put as much business logic as possible in my Domain Model.

  • 0

I try to put as much business logic as possible in my Domain Model.

Every time MyEntity is updated, I want two things to happen:

  1. Send a message to the user who created it
  2. Check if the changes apply to certain business rules

If the entity is not a child of an aggregate root.

Normally I would get the specific entity from the repository. Change the entity, and persist it
back to the DB using MyRepository.Save()

In this case I’d have to put the business logic in my application or in the DAL, not in the Domain Model. I’m trying to avoid using a business logic layer unless absolutely necessary, but I can’t seem to fit this in unless I make a method called MyEntity.Update() or something like that but I have a feeling that is not the right way to do it.

  • 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-05-31T01:24:22+00:00Added an answer on May 31, 2026 at 1:24 am

    First let me state, I am not against Repository patterns. I recently used one successfully on a project.

    I would say exercise caution … and if you can’t encapsulate the requirements in your objects your OO approach might need to be looked at again. Introducing a Data Access layer for the purposes of doing other things seems to be a code smell. I have used a Service Layor to receive requests and manage transactions and versioning however not for additional things like validation and so on. Potentially your service layor could look like the following.

        public enum UpdateResult
        {
             Success,
             NoMyEntityFound,
             StaleData,
             InvalidRequest
        }
    
    
    public class MyService
    {
    
    
         ...
         ...
    
    
         public UpdateResult Update(...)
         {
              ...Start Tran
              ...Load var m = MyEntity
              ...do the bare minimum here 
              ...m.Update()
              ...Commit Tran
    
              return UpdateResult.Success;
         }
    
    }
    

    Having said all that a cautionary tail on repositories

    http://ayende.com/blog/3955/repository-is-the-new-singleton

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

Sidebar

Related Questions

I'll try to provide as much context as possible. Been trying to override Mage_GoogleShopping_Model_Attribute_Link
I'm gonna try and simplify this as much as possible. Lets say i have
I never really put too much time on optimizing website. Sure i put script
i try to put the progress bar into the notification. but the problem is
I try to put some HTML link behind input text and I try to
I try to put sixteen checkbuttons into frame, placing them into four columns like:
Scenario : I'll try to put an analogy with the loan broker example from
When I try to put a value into a DATE field which is invalid,
I’m using C# and WinForms to try and put just the date from a
im near to finish my app and when try to put in onlin server

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.