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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:01:27+00:00 2026-05-27T10:01:27+00:00

I have the tables: Player Id : int – primarykey Name : string BowlerType

  • 0

I have the tables:

Player
Id : int – primarykey
Name : string

BowlerType
Id : int – primarykey
Description : string

PlayerBowlerType
PlayerId : int not null foreign key referencing Player.Id
BowlerTypeId : int not null foreign key referencing BowlerType.Id

A player can confirm to many bowling types. heres some example data

Player
1 | Peter
2 | John

BowlerType
6 | Slow
7 | Fast

PlayerBowlerType
1 | 6
1 | 7
2 | 7

  • 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-27T10:01:28+00:00Added an answer on May 27, 2026 at 10:01 am

    What you need here is a composite id to use with your PlayerBowlerType. This setup should work:

    public class PlayerBowlerTypeId
    {
        public virtual int PlayerId { get; set; }
    
        public virtual int BowlerTypeId { get; set; }
    
        public override bool Equals(object obj)
        {
            return Equals(obj as PlayerBowlerTypeId);
        }
    
        private bool Equals(PlayerBowlerTypeId other)
        {
            if (ReferenceEquals(other, null)) return false;
            if (ReferenceEquals(this, other)) return true;
    
            return PlayerId == other.PlayerId &&
                BowlerTypeId == other.BowlerTypeId;
        }
    
        public override int GetHashCode()
        {
            unchecked 
            {
                int hash = GetType().GetHashCode();
                hash = (hash * 31) ^ PlayerId.GetHashCode();
                hash = (hash * 31) ^ BowlerTypeId.GetHashCode();
    
                return hash;
            }
        }
    }
    
    public class PlayerBowlerType
    {
        public PlayerBowlerType()
        {
            Id = new PlayerBowlerTypeId();
        }
    
        public virtual PlayerBowlerTypeId Id { get; set; }
    }
    
    public class PlayerBowlerTypeMap : ClassMap<PlayerBowlerType>
    {
        public PlayerBowlerTypeMap()
        {
            Table("TABLENAME");
    
            CompositeId<PlayerBowlerTypeId>(x => x.Id)
                .KeyProperty(x => x.BowlerTypeId, "COLUMNNAME")
                .KeyProperty(x => x.PlayerId, "COLUMNNAME");
        }
    }
    

    You can technically do this without an identity object (the PlayerBowlerTypeId type would be removed and the code placed directly into the PlayerBowlerType and suitably adapted), but I’ve had a number of problems (3-4 separate bugs) caused by doing this. One of them is discussed here.

    While I hate changing the domain objects to compensate for bugs in the ORM system, if you just use the PlayerBowlerTypeId type, it will save you a lot of headaches.

    This should work as long as you modify the mapping to use your actual table and column names (and whatever else you need to do with the mapping for your particular setup).

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

Sidebar

Related Questions

I have two tables in the database Team:Id(int PK), Name(nvarchar) and Player:Id(int PK), Name(nvarchar),
I have 3 tables: Player => PlayerId (Primary Key), Name, etc Team => TeamId
I have tables like this: tblUsers int UserID string UserName tblUsersInRoles int UserID int
I have two tables Players table (object) ------------- PlayerID Name Birthday List<Matches> Matches and
Suppose you have two tables: Musicians musicianID (primary key, int) name (varchar) instrument (varchar)
I have 3 tables like this player(id,name,age,teamid) team(id,name,sponsor,totalplayer,totalchampion,boss,joindate) playerdetail(id,playerid,position,number,allstar,joindate) I want to select teaminfo
I have a table Player with columns id, name, wins, games_played. I mapped it
When I have tables in my database that have PK/FK relationships (int) and when
so i have 2 tables: -char (keeps information about the player) -special (its a
I have a structure like struct board{ char name; int values[37]; }board Imagine a

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.