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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:08:40+00:00 2026-05-23T22:08:40+00:00

Sorry for long title, the question is rather simple: I have 2 classes, Player

  • 0

Sorry for long title, the question is rather simple:

I have 2 classes, Player and Role (they are activerecord table)

class Player
{
    ...Various fields...

    [BelongsTo("RoleId")]
    public Role Role {get;set;}
}

class Role
{
    ...Various fields...

    [Property]
    public string Name {get;set;}
}

A Player, can have only one role, but (for me), it doesn’t matter if Role has 0-1-2-many players, so I would like to omit HasMany attribute (my example is easy, but my database is much bigger than this). Role is behaving like a user-defined enum, is possible to do this? Which is the correct way?

Edit 1:
What if I have a similar situation but I need that a Role belogs only to one player (onetoone), but again I would like to omit the part from the “Role” class (so role doesn’t know anything about this association)

  • 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-23T22:08:41+00:00Added an answer on May 23, 2026 at 10:08 pm

    If you specify BelongsTo attribute and not HasMany attribute, what I want is already done, the Role doesn’t matter if has 0-1-2-many players.

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

Sidebar

Related Questions

Sorry for the long title. I have a typedef in a class List: template
Sorry for the long question title. I guess I'm on to a loser on
Sorry for a long question and not a very descriptive title, but my problem
Sorry for the long title, but it seems most descriptive for my question. Basically,
(sorry about the long title) I have a custom object Person, which in turn
sorry about the long title! I have a windows server 2003. I want to
Sorry for the long winded title, but the requirement/problem is rather specific. With reference
Sorry the title is a little bit long. So I have a twitter account
Sorry for the long and yet still somehow vague title! A friend of mine
Sorry for this long post. The question is however small but requires full detail.

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.