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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:38:39+00:00 2026-05-23T02:38:39+00:00

I’m unsure how to deal with the UserDetail class. Program; A virtual account hierarchy,

  • 0

I’m unsure how to deal with the UserDetail class.

Program; A virtual account hierarchy, with UserAccounts which can only have transactions towards a MainAccount. But the UserAccounts can place some type of bets, which will be a profit/loss towards the account balance.

It feels logical to have MainAccount as the database aggregate root, as the accounts form the most important data. As it looks now, it may seem ok to have the UserDetail as part of the account aggregate, but I it could be useful to create a user even before an account has been created. And perhaps a user also may be allowed to have two accounts. Then what?

I guess the UserDetail could be simply a stand-alone aggregate. But in such case, how would I load the respective UserDetail when loading the account aggregate?

Please, if you have some thoughts around this, would be much appreciated.

Btw, I’m using FluentNHibernate.

Domain:

    public class MainCashAccount
    {
        public int Id { get; set; }
        public IList<UserCashAccount> UserCashAccounts { get; set; }
        public IList<Transaction> UserAccountTransactions { get; set; }
    }
    public class UserCashAccount
    {
        public int Id { get; set; }
        public UserDetail User { get; set; }
        public IList<Bet> Bets { get; set; }

        public UserConnection Connection { get; set; }   // Not persisted/mapped
    }
    public class UserDetail
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string LoginName { get; set; }
        public string Password { get; set; }
    }

Other:

    public class UserConnection
    {
        public TcpClient TcpClient { get; set; }

EDIT:

Possible solutions: (??)

One-Directional

Class UserCashAccountMap
   ...
   HasOne(x => x.User).Cascade.None()

Bi-Directional

Class UserDetail
   ...(as above)
   public UserCashAccount Account {get; set;}

Class UserCashAccountMap
   ...
   HasOne(x => x.User).Cascade.None()

Class UserDetail
   HasOne(x => x.Account).Cascade.None().Inverse()

..Or Reference instead of HasOne, for allowing multiple accounts per user.

  • 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-23T02:38:40+00:00Added an answer on May 23, 2026 at 2:38 am

    I guess the UserDetail could be simply a stand-alone aggregate. But in such case, how would I load the respective UserDetail when loading the account aggregate?

    By having the primary key of the MainAccount object be a foreign key on the UserDetail object.

    The question you specifically revolves around to have self referencing entities or not, from your statements I quoted you could define your model in a bunch of ways. You could do

    public class UserCashAccount {
        public IList<UserDetail> Details {get;set;}
    }
    
    public class Details {
        public UserCashAccount Account {get;set;}
    }
    
    public class UserCashAccount {
        public Guid UserDetailsId {get;set;}
    }
    
    public class Details {
        public Guid AccountId {get;set;}
    }
    

    or any combination of these 2. You can also choose to not reference 1 side of this relationship at all and not have a bi-directional relationship.

    Edit: Responding to your comment. You do not want to use HasOne(), HasOne is an extremely rare type of association that is truly 1-to-1, almost no databases ever have relationships coded as a 1-to-1 they are almost always many-to-1. This is a References() relationship.

    In the situation of a HasOne both objects share the same primary key. This design is almost never used in database systems.

    One note I did originally have an error in my design, to have a bi-directional association the UserDetails would actually be a collection on the UserAccount object to avoid requiring a true HasOne association.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

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.