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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:51:39+00:00 2026-05-14T21:51:39+00:00

I am creating the security system for the software im creating and I would

  • 0

I am creating the security system for the software im creating and I would like to know how i can do the following in NHibernate(if at all possible)

User Account Class:

public class UserAccount
{
    public virtual int UserID { get; set; }
    public virtual String Username { get; set; }
    public virtual Privilege InvoicePrivilege { get; set; }
    public virtual Privilege TradePrivilege { get; set; }
}

Privilege Class:

public class Privilege
{
    public virtual bool Read { get; set; }
    public virtual bool Write { get; set; }
    public virtual bool Delete { get; set; }
    public virtual bool Modify { get; set; }
}

I will be having a large number of these privilege objects (one for each traded entity) so in the database i have the following tables:

UserAccounts ( UserID, Username)
Privileges (UserID, PrivilegeType, Read,Write,Modify,Delete)

How can I map the InvoicePrivielge property from the user account to the (UserID, ‘Invoice’) Privilege.

I could do this using many-to-one but I don’t want a collection of privileges, i’d rather map it to its property.

  • 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-14T21:51:40+00:00Added an answer on May 14, 2026 at 9:51 pm

    I think a way to do this is to create two subclasses of the Privilege class:

    public class InvoicePrivilege : Privilege 
    {
    }
    public class TradePrivilege : Privilege
    {
    }
    

    and set the discriminator column and value. In fluent mapping:

    public class PrivilegeMap : ClassMap<Privilege>
    {
      public PrivilegeMap()
      { 
         // ...
         DiscriminateSubClassesOnColumn("PrivilegeType")
           .SubClass<InvoicePrivilege>("Invoice", x => x.Map( ... ))
           .SubClass<TradePrivilege>("Trade", x => x.Map( ...));
      }
    }
    

    and use the subclasses in the UserAccount

    public virtual InvoicePrivilege InvoicePrivilege { get; set; }
    public virtual TradePrivilege TradePrivilege { get; set; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All reservations about unsecuring your SecureString by creating a System.String out of it aside
In our system we are reading user security groups from an Active Directory in
I've been trying to track down why Spring Security isn't creating the Spring Security
I'm creating a web app (locally, so security doesn't matter) in PHP where the
I am new to Spring Security. I have been working on creating a custom
Hi, I am creating an app with tabactivity . But for security reasons i
Creating a class at runtime is done as follows: klass = Class.new superclass, &block
Creating a google map with store locations within 50 miles of user entered address.
I'm using the following code in an attempt to programatically allow the NetworkService account
I'm creating a login system and want to block the person trying to log

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.