I have a database table that I cannot change that contains data such as:
FooTable
Id | EntityAUniqueId | EntityBUniqueId | EntityCUniqueId
============================================================
1 | A1 | B1 | C1
2 | A1 | B1 | C2
3 | A1 | B2 | C3
4 | A1 | B2 | C4
5 | A2 | B3 | C5
6 | A2 | B3 | C6
7 | A2 | B4 | C7
8 | A2 | B4 | C8
I want to match this with the following structure:
interface IEntityA
{
string UniqueId { get; }
IEnumerable<IEntityB> { get; }
}
interface IEntityB
{
string UniqueId { get; }
IEnumerable<IEntityC> { get; }
}
interface IEntityC
{
string UniqueId { get; }
}
class EntityA : IEntityA { ... }
class EntityB : IEntityB { ... }
class EntityC : IEntityC { ... }
The above data will stretch the following objects:
EnityA(A1)
|-EnityB(B1)
| |-EntityC(C1)
| |-EntityC(C2)
|-EnityB(B2)
|-EntityC(C3)
|-EntityC(C4)
EnityA(A2)
|-EnityB(B3)
| |-EntityC(C5)
| |-EntityC(C6)
|-EnityB(B4)
|-EntityC(C7)
|-EntityC(C8)
Currently, I only need to write to a table that is not readable.
I am using FluentNHibernate with AutoMapping and conventions.
I began to walk the Components road, but I realized that this is not what they are intended for. One possible solution would be to use three views in the table, but this adds additional problems, and I would like to avoid this if possible, and I cannot understand that there should be something already in this area in this area.
If interfaces confuse the answer, feel free to omit them from the solution.