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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:28:33+00:00 2026-05-13T00:28:33+00:00

Using Fluent NHibernate I need a clue how to map my Invoice class. public

  • 0

Using Fluent NHibernate I need a clue how to map my Invoice class.

public class Buyer
{
    public virtual int Id { get; set; }

    public virtual string Name { get; set; }
    public virtual string TaxRegNo { get; set; } 
    // .... more properties....
}

public class Invoice
{
    public virtual int Id { get; set; }

    public virtual int IdBuyer { get; set; }
    public virtual Buyer Buyer { get; set; } 
    // ....more properties
}

The problem is that I want to have in Invoice class:

  • BuyerId – just an integer ID for reference and foregin key relationship
  • a copy of almost all buyer properties (its accounting document and properties cannot be changed after confirmation) – as component

I tried to this using following mapping but it doesn’t work

    public InvoiceMap()
    {
        Id(x => x.Id);

        References(x => x.IdBuyer);
        Component(x => x.Buyer, BuyerMap.WithColumnPrefix("buyer_"));
    // ....more properties
    }
  • 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-13T00:28:33+00:00Added an answer on May 13, 2026 at 12:28 am

    You would normally not map both the foreign key and the child object. If you do map both, then do this in the mapping (or similar):

    References(x => x.Buyer);
    Map(x => x.IdBuyer).Column("BuyerId").Not.Insert().Not.Update();
    

    Then you don’t double up on the column name in SQL statements, which causes errors around mismatched numbers of parameters.

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

Sidebar

Related Questions

I'm using Fluent NHibernate and need to get my Connection String from the connection.connection_string
Is it possible to map an enum as a string using Fluent Nhibernate?
I'm using Fluent Nhibernate and my relevant entities are: public class Product { public
I'm using Fluent NHibernate auto mapping. I need to access more than one database
I am trying to map several tables using Fluent Nhibernate. My tests are giving
I am trying to set up proper domain architecture using Fluent NHibernate and Linq
I have mapped a simple entity, let's say an invoice using Fluent NHibernate, everything
I'm using Fluent NHibernate in order to auto map my entities. This is the
I am using Fluent NHibernate to map out an existing database. For this reason
When ever you set a string value in fluent NHibernate it alwasy sets the

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.