4

I'm developing an app that has a model using race results / times etc..
I've got a model that looks something like:

public class Competitor
{
    public virtual int ID { get; set; }
    public virtual string Name { get; set; }
    public virtual DateTime DateOfBirth { get; set; }
}

public class Event
{
    public virtual int ID { get; set; }
    public virtual string Name { get; set; }
    public virtual string Description { get; set; }
}

public class Result
{
    public virtual int ID { get; set; }
    public virtual decimal ResultTime { get; set; }
    public virtual Competitor Competitor { get; set; }
    public virtual Event Event { get; set; }
}

In my database, I only have access to Views which represent a "flat" view of the data. This would look something like:

vResult

ResultID
ResultTime
CompetitorID
CompetitorName
CompetitorDateOfBirth
EventID
EventName
EventDescription

So, I'm trying to avoid having a class that matches the above "flat" schema entirely (if possible)

Is it possibly to map this with Fluent nHibernate?

EDIT-
It's worth mentioning, data access will be read only

Alex
  • 37,502
  • 51
  • 204
  • 332
  • not a full answer, but I know it involves `ComponentMap`. Possibly related: http://stackoverflow.com/questions/4250749/fluent-nhibernate-component-one-to-many http://stackoverflow.com/questions/4250749/fluent-nhibernate-component-one-to-many http://stackoverflow.com/questions/1241897/nhibernate-component-with-a-one-to-many-relation-from-parent – hometoast Jun 26 '12 at 12:57
  • i thought components were for normalized data, this however is de-normalized? – Alex Jun 26 '12 at 13:28
  • https://github.com/jagregory/fluent-nhibernate/wiki/Fluent-mapping contradicts itself. "_these properties are stored in the same table as the parent entity in a normalised fashion._" But Component is for mapping columns out to a separate object. – hometoast Jun 26 '12 at 14:13

1 Answers1

3

As comments above indicated, it was indeed Component that solved this.

Along the lines of the following in my ResultMap class:

Component(x => x.Event, m =>
            {
                m.Map(x => x.ID).Column("EventID");
                m.Map(x => x.Name).Column("EventName");
                m.Map(x => x.Description).Column("EventDescription");
            });
Alex
  • 37,502
  • 51
  • 204
  • 332