views:

13

answers:

0

I have a database table with Sqlite structure:

CREATE TABLE Cashflows
(
    Id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    Fund_Id INTEGER NOT NULL,
    CashflowDate DATETIME NOT NULL,
    CashflowType INTEGER NOT NULL,
    CashflowValue DOUBLE NOT NULL
);

Fund_Id is just a standard reference to the Fund table.

In Fluent NHibernate, I'd like to map it in such a way that I can set up the domain to do lookups like this:

double cashflowValue = Fund.Cashflows[DateTime.Today][CashflowTypes.Normal].CashflowValue;

So I guess I have to use some kind of nested Map.

Alternatively, I can create a CashflowKey class:

public class CashflowKey
{
    public virtual DateTime CashflowDate {get; set;}
    public virtual CashflowTypes CashflowType {get; set;}
}

And do lookups as follows:

CashflowKey key = new CashflowKey() {
    .CashflowDate = DateTime.Today,
    .CashflowType = CashflowTypes.Normal };

double cashflowValue = Fund.Cashflows[key].CashflowValue;

Any of the two solutions is acceptable. However, I've been unable to map this successfully with Fluent NHibernate. I've tried Entity Maps, Components and everything else that I could think of. Surely this is a simple enough scenario so that FH can support it?