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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:23:00+00:00 2026-05-29T08:23:00+00:00

I am implementing the Fowler’s Accountability Pattern. I have Party with subclasses User, and

  • 0

I am implementing the Fowler’s Accountability Pattern. I have Party with subclasses User, and PeopleGroup. I have Accountability and AccountabilityType. I have Party mapped as a table and User and PeopleGroup both mapped as separate tables. Then lastly there’s an Accountability_Party cross reference table.

So this all works fine, however, here’s the problem.
If I get a peoplegroup and say

pg.ChildAccountablities.Where(x=>x.PartyType == "User")

thus getting all the Parties that are of type User, I can not then cast the Party to a User. This I guess is upcasting.

The reason I need to do this is because I’m using a permissioning system that has an interface on User (IUser) to identify it. I would like to say get all the users assigned to this peoplegroup and give them this permission. But the permissioning system interface requires a class with the IUser interface on it for the assignment and of course Party does not have that
Perhaps I could say something like

_repository.Query<User>(x=>x.ParentAccountabilities.Any(y=>y.Parent == myPeopleGroup))

but that seems like kind of a roundabout way of doing it.

Any thoughts or insights into this problem would be greatly appreciated.

Thanks,

Raif

Update

here is a link to the accountability pattern by Fowler .

Also the code or rather the mappings are as follows

public class PartyMap : DomainEntityMap<Party>
{
    public PartyMap()
    {
        HasManyToMany(x =>x.ParentAccountabilities).Access.CamelCaseField(Prefix.Underscore).LazyLoad();
        HasManyToMany(x =>x.ChildAccountabilities).Access.CamelCaseField(Prefix.Underscore).LazyLoad();
    }
}

public class PeopleGroupMap : SubclassMap<PeopleGroup>
{
    public PeopleGroupMap()
    {
        Map(x => x.Name);
    }
}

public class UserMap : SubclassMap<User>
    {
        public UserLoginInfoMap()
        {
            Map(x => x.LoginName);
            Map(x => x.Password);
            blah blah blah
        }
    }

public class AccountabilityMap : DomainEntityMap<Accountability>
{
    public AccountabilityMap()
    {
        References(x => x.Parent);
        References(x => x.Child);
        References(x => x.AccountabilityType);
    }
}

public class AccountabilityTypeMap : DomainEntityMap<AccountabilityType>
{
    public AccountabilityTypeMap()
    {
        Map(x => x.Name);
    }
}

The DomaineEntityMap is just a map of DomainEntity from which all entities inherit and which has some basic stuff like created date modified date etc.

thx

  • 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-29T08:23:01+00:00Added an answer on May 29, 2026 at 8:23 am

    the code for Accountability would help but i guess it has a Reference to Party which is lazyloaded. NH then creates a proxy deriving from party to represent the lazyloaded party instance. possible solutions

    1. disable lazy loading of the Party reference
    2. change the reference to referenceany(FluentMapping)/any(hbm mapping)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When implementing Quicksort, one of the things you have to do is to choose
I am following the presentation model design pattern suggested by Martin Fowler for my
Implementing Document-View pattern I faced the problem: standard generic collections and dictionaries ( List<T>
Implementing swing applications, often you realize class of components that should have a coherent
Im implementing a ZoomButtonsController in my custom View and have been trying to figure
Implementing Equals() for reference types is harder than it seems. My current canonical implementation
Implementing a 'sandbox' environment in Python used to be done with the rexec module
Implementing the ScriptControlClass was extremely easy, unfortunately the side effects with the language implementation
implementing publishActivity in PHP using the REST API using this code: $activity = array(
When implementing a needle search of a haystack in an object-oriented way, you essentially

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.