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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:07:10+00:00 2026-06-04T04:07:10+00:00

What is wrong with my class mappings below? public class Foo { public Foo()

  • 0

What is wrong with my class mappings below?

public class Foo
{
    public Foo()
    {
        ActualCurve = new List<Point>();
        TargetCurve = new List<Point>();
    }
    public virtual int Id { get; set; }
    public virtual string Name { get; set; }
    public virtual IList<Point> ActualCurve { get; set; }
    public virtual IList<Point> TargetCurve { get; set; }
}

public class Point
{
    public virtual int Id { get; set; }
    public virtual double X { get; set; }
    public virtual double Y { get; set; }
}

public class FooMapping() : ClassMap<Foo>
{
    Table("Foos");
    Id(x => x.Id).GeneratedBy.Identity();
    Map(x => x.Name).Not.Nullable();
    HasMany(x => x.ActualCurve ).Cascade.All();
    HasMany(x => x.TargetCurve ).Cascade.All();
}

public class PointMapping() : ClassMap<Point>
{
    Table("Points");
    Not.LazyLoad();
    Id(x => x.Id).GeneratedBy.Identity();
    Map(x => x.X).Not.Nullable();
    Map(x => x.Y).Not.Nullable();
}

These mappings produce

CREATE TABLE [dbo].[Foos](
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [Name] [nvarchar] NOT NULL,
    [RecipeRevisionId] [int] NOT NULL

CREATE TABLE [dbo].[Points](
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [X] [float] NOT NULL,
    [Y] [float] NOT NULL,
    [FooId] [int] NOT NULL

Essentially, the problem is that when I am pulling a persisted Foo object back out of the database, the Foo.ActualCurve and Foo.TargetCurve lists both get populated with the combined contents of both lists. There clearly isn’t a column that keys which set of points belong to the correct curve within Foo, but I am not sure how to change the mapping to maintain the two distinct sets of Points.

  • 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-04T04:07:11+00:00Added an answer on June 4, 2026 at 4:07 am

    I think you will need to specify a separate column for the references:

    HasMany(x => x.ActualCurve ).Cascade.All().KeyColumn("ActualCurveId");
    HasMany(x => x.TargetCurve ).Cascade.All().KeyColumn("TargetCurveId");
    

    EDIT: Column->KeyColumn

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

Sidebar

Related Questions

Correct me If Im wrong. public class Person{ List<Cars> myCars; //Get and Set }
I'm feeling dumb. public class Uber { public Foo Foo { get; set; }
I've created 2 objects: public class Set { public Set() { _sorts = new
I have an entity like so: public class Land { public virtual IDictionary<string, int>
I have the following entities public abstract class Card { public virtual int Id
I wonder if there is something wrong with the copy constructor function below? class
Can anyone tell me what is wrong with this code? public abstract class BoardTestBean{
I use a Where clause in my FluentNHibernate mappings as follows: public class FooMap
What am I doing wrong here: class Helo { // main: generate some simple
Is there anything wrong with having a single class (one .h) implemented over multiple

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.