views:

25

answers:

0

I have the following tables and i have no control on the table schema

DocumentText
{
 NoteId
 OutputType
 Note_Text
}

OrderCoordinator
{
   AuthoriserCode
   Value
}

DocumentText joined to OrderCoordinator on (Note_Text = AuthoriserCode) only when Outputtype='PRTYPE'

How do i map this using fluent nhibernate

i am currently mapping as follows but lot of sql statements are executed for every record in document text

public DocumentTextMap()
    {
        Table("DOCUMENT_TEXT");
        CompositeId().KeyProperty(x => x.NoteId,"NOTE_ID").KeyProperty(x => x.OutputType, "OUTPUT_TYPE");
        Map(x => x.NoteId).Column("NOTE_ID");
        References(x => x.PurchaseRequisition).Column("NOTE_ID").ForeignKey("NOTE_ID").LazyLoad();
        Map(x => x.NoteText).Column("NOTE_TEXT");
        Map(x => x.OutputType).Column("OUTPUT_TYPE");
        References(x => x.OrderCoordinator).Column("NOTE_TEXT").ForeignKey("AUTHORIZE_CODE").Fetch.Join().NotFound.Ignore().Not.LazyLoad();            
    }