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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:13:24+00:00 2026-06-01T00:13:24+00:00

Have three classes User, Group and Field. Many to many relationship on User /

  • 0

Have three classes User, Group and Field. Many to many relationship on User / Group and a many to many relationship on Group Field. The User / Group relationship is pretty simple as a User is simply a member of the Group or not. The Group / Field relationship is more complex as there is an Authority property on that relationship.

In the ctor I pass HashSets of the relationships so there is one master.

Finally to the question. How can I filter to the Group FieldAuthority better? See ?? in code below.

    public class Group : Object
    {
        private HashSet<UserGroup> usersGroups;
        private HashSet<GroupFieldAuthority> groupsFieldsAuthority;

        public Int16 ID { get; private set; }
        public string Name { get; set; }

        public List<User> Users
        { get { return usersGroups.Where(x => x.Group == this).Select(x => x.User).OrderBy(x => x.UserID).ToList(); } }
        public List<FieldAuthority> FieldsAuthority
        {     
            get
            {
                // Can this be done more directly??
                List<FieldAuthority> fieldsAuthority = new List<FieldAuthority>();
                foreach (GroupFieldAuthority gfa in groupsFieldsAuthority.Where(x => x.Group == this).OrderBy(x => x.Group.Name))
                {
                    fieldsAuthority.Add(new FieldAuthority(gfa.FieldDef, gfa.Authority));
                }
                return fieldsAuthority;
            }
        }
        public override bool Equals(Object obj)
        {
            //Check for null and compare run-time types.
            if (obj == null || GetType() != obj.GetType()) return false;
            Group fd = (Group)obj;
            return (ID == fd.ID);
        }
        public override int GetHashCode() { return (int)ID; }
        public Group(Int16 id, string name, HashSet<UserGroup> UsersGroups, HashSet<GroupFieldAuthority> GroupsFieldsAuthority)
        { ID = id; Name = name; usersGroups = UsersGroups;  groupsFieldsAuthority = GroupsFieldsAuthority; }
    }
    public class GroupFieldAuthority : Object
    {
        public Group Group { get; private set; }
        public FieldDef FieldDef { get; private set; }
        public enumAuthRORWMADeny Authority { get; private set; }
        public override bool Equals(Object obj)
        {
            //Check for null and compare run-time types.
            if (obj == null || GetType() != obj.GetType()) return false;
            GroupFieldAuthority item = (GroupFieldAuthority)obj;
            return (Group.ID == item.Group.ID);
        }
        public override int GetHashCode() { return (int)Group.ID ^ (int)FieldDef.ID; }
        public GroupFieldAuthority(Group group, FieldDef fieldDef, enumAuthRORWMADeny authority)
        { Group = group; FieldDef = fieldDef; Authority = authority; }
    }
    public class FieldAuthority : Object
    {   // used for FieldDef and Document
        public FieldDef FieldDef { get; private set; }
        public enumAuthRORWMADeny Authority { get; private set; }
        public override bool Equals(Object obj)
        {
            //Check for null and compare run-time types.
            if (obj == null || GetType() != obj.GetType()) return false;
            FieldAuthority item = (FieldAuthority)obj;
            return (FieldDef.ID == item.FieldDef.ID);
        }
        public override int GetHashCode() { return (int)FieldDef.ID; }
        public FieldAuthority(FieldDef fieldDef, enumAuthRORWMADeny authority)  
        { FieldDef = fieldDef; Authority = authority; }
    }
  • 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-06-01T00:13:25+00:00Added an answer on June 1, 2026 at 12:13 am

    Is that what do you want?

    return groupsFieldsAuthority
             .Where(x => x.Group == this)
             .OrderBy(x => x.Group.Name)
             .Select(x => new FieldAuthority(x.FieldDef, x.Authority))
             .ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assuming I have classes User and UserGroup. There is an optional 1-many group to
I have two domain classes with a many-2-many relationship between them, e.g. User and
I have three classes; User, Feed, and Entries. Users have one or more Feeds
I have three (C++) classes: Player, Hand, and Card. Player has a member, hand,
I have three classes (domain, role and user). Domain and role are properties of
I have three classes that need to be related, and I'm not sure how
I have a two entity classes called User and Group, both reserved words that
I have three entities: User, Office and PhoneNumber. The user has many phone numbers,
I currently have three classes User , UserProfile , and Vendor . User is
I have three classes that all have a static function called 'create'. I would

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.