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 540031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:11:52+00:00 2026-05-13T10:11:52+00:00

I’m new to DDD so please forgive me if I’m not using the terms

  • 0

I’m new to DDD so please forgive me if I’m not using the terms correctly.

I am Using C# MS/SQL and NHibernate.

I have a class call Payment and this payment has a PaymentCurrency each of these is an entity in the database.

OK. In my Domain Model I want to be able to create Payment as Either

Payment p = new Payment( 100 ) // automatically uses the default currency (defined in the db )

or

Payment p = new Payment( 100, Repository.GetCurrency( "JPY" ) ) // uses Yen defined in the db.

But it seems to me that in order to initialize my Domain Object with the dfault currency I need to pollute the domain model with knowledge of persistance. i.e. before I can completed the default Payment Constructor I need to load the Default Payment object from the db.

The constructor I visualize is somehting like

public Payment( int amount ) {
   Currency = Repository.LoadDefaultCurrency();  // of cource defualt currency would be a singleton
}

public Payment( int amount, Currency c ) {
   Currency = c; // this is OK since c is passed in from outside the domain model.
}

Thanks for your advice.

  • 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-13T10:11:53+00:00Added an answer on May 13, 2026 at 10:11 am

    I don’t think there’s a perfect solution to this, but you can avoid putting the persistence code into domain classes by having the default currency (and similar properties) stored on some other class (eg. “DomainDefaults”) and have it initialised from another piece of code that logically sits “above” the domain objects. Of course, you’d have to make sure that initialisation code is called before any domain objects can be created. It should probably throw an exception if not initialised, so you can at least catch this easily.

    So the constructor becomes

    public Payment( int amount )
    {
       Currency = DomainDefaults.DefaultCurrency;
    }
    

    And somewhere soon after you initialise NHibernate you’d call:

    DomainDefaults.DefaultCurrency = Repository.GetCurrency("JPY")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
This could be a duplicate question, but I have no idea what search terms
I have thousands of HTML files to process using Groovy/Java and I need to
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.