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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:59:59+00:00 2026-05-13T07:59:59+00:00

I am new to all the OOP and ORM stuff, so i would appreciate

  • 0

I am new to all the OOP and ORM stuff, so i would appreciate your help…

I have a Team Class:

public class Team : IEntity<Team>
{
    public virtual int ID { get; private set; }

    public virtual string Code{ get; private set; }

    public virtual TeamWorker TeamLeader { get; private set; }

    public virtual IEnumerable<TeamWorker> Workers {get; private set;}
    //etc

}

A Worker Class:

public class Worker: IEntity<Worker>
{
    public virtual int ID { get; private set; }

    public virtual string Name { get; set; }
    //etc
}

A Team Worker Class, that “glues” a Worker to a percentage of the total value that will be given to a Team:

   public class TeamWorker
   {
        public virtual Worker Worker{ get; private set; }
        public virtual Percentage Comission{ get; private set; }
   }

And the Percentage class from wich i just need the public decimal Value property

So far i was able to map the Leader in the Team:

public class TeamMap : ClassMap<Team>
{

    public TeamMap()
    {
        Table("Team");

        Id(e => e.ID, "ID").GeneratedBy.Identity();

        Map(e => e.Code, "Code").Unique().Not.Nullable();

        Component(team => team.Leader,
                  m =>
                  {
                      m.References(teamWorker => teamWorker.Worker, "IDTeamWorker").Cascade.SaveUpdate();
                      m.Component(teamWorker  => teamWorker.Commission,
                                  p =>
                                  p.Map(commission=> commission.Value, "LeaderCommission").
                                      CustomType(typeof(decimal)).Nullable());
                  }
            );

  }

}

this maps the Leader and his commision in the team table, the problem i’m having is mapping the Workers…

i tried this:

    HasMany(team => team.Workers).Table("TeamWorkers").Component(m =>
                                            {
                                                m.References(twk => twk.Worker).Cascade.SaveUpdate();
                                                m.Map(twm => twk.Commission, "Commission");
                                            }
            );

But then i got this:
Could not determine type for: Percentage

this happens because Commission is a Percentage and i didn’t map it because its a value object, if only i could do this:

 HasMany(team => team.Workers).Table("TeamWorkers").Component(m =>
                                            {
                                                m.References(twk => twk.Worker).Cascade.SaveUpdate();
                                                m.Component(twk => twk.Commission,
                                      m2 => m2.Map(commission=> commission.Value, "Comission").CustomType(typeof(decimal)).Nullable());
                                            }
                );

but Component its not an option in this context…

i need to find a way to have

TeamWorkers table with TeamId WorkerId and Commission

TeamID and WorkerID are foreign keys from Team and Worker table, and Commission is the value property in Percentage class.

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

    Don’t use Component, that’s for value types and dealing with normalized tables. You need to be creating proper mappings for your Worker and TeamWorker, and treat them as proper entities.

    Create a WorkerMap and TeamWorker map, then you can update your TeamMap to just use HasMany(x => x.Workers).

    As for Percentage, you either need to map that with it’s own ClassMap, or use Component inside of your new TeamWorker map.

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

Sidebar

Ask A Question

Stats

  • Questions 309k
  • Answers 309k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Because In Python, bool is the subclass/subtype of int. >>>… May 13, 2026 at 9:54 pm
  • Editorial Team
    Editorial Team added an answer There are several approaches to dealing with email forgery: Use… May 13, 2026 at 9:54 pm
  • Editorial Team
    Editorial Team added an answer If you mean a string 000...111... where the length of… May 13, 2026 at 9:54 pm

Related Questions

I am new to programming (6 weeks now). i am reading a lot of
I have my first ever interview for a Java developer role, specifically RMI, Serverlets
I am new to OOP Javascript and am having trouble with the this keyword
I am new to C# (and OOP ). When I have some code like
Again disclaimer disclaimer still learning C# and OOP generally so I hope you'll be

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.