Display a flat view of the free class hierarchy nHibernate

I am developing an application in which there is a model using race results / time, etc.

I have a model that looks something like this:

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 that are a β€œflat” view of the data. It will look something like this:

vResult

ResultID
ResultTime
CompetitorID
CompetitorName
CompetitorDateOfBirth
Eventid
Eventname
Eventdescription

So, I try to avoid having a class that matches the above β€œflat” schema completely (if possible)

Is this possible to match with Fluent nHibernate?

EDIT -
It should be noted that data access will be read-only

+4
source share
1 answer

As stated above, it really was a Component that resolved this.

In the lines of the following in the 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"); }); 
+3
source

All Articles