0

I'm having trouble figuring out how to map an interface while using a composite key.

What I'm trying to do is this:

interface Ifoo
{
  int someInt {get;}
  int id {get;}
}

class bar1: Ifoo
{
  int someInt {get; protected internal set;}
  int id {get; protected internal set;}
}

class bar2: Ifoo
{
  int someInt {get; protected internal set;}
  int id {get; protected internal set;}
}

class someOtherClass
{
  Ifoo myFoo {get; protected internal set;}
  int id {get; protected internal set;}
}

public class someOtherClassMap: ClassMap<someOtherClass>
{
  CompositeId()
    .KeyReference(x => x.myFoo, "fooID")
    .KeyProperty(x => x.id, "id");

  References(x => x.myFoo)
    .Class(typeof (foo1))
    .Class(typeof (foo2))
    .Column("fooID")
    .Not.Insert()
    .Not.Update();
}

The References works without issue, but I can't get the KeyReference to work, and there doesn't seem to be any ".Class" I can use like I can with References.

I read:

Fluent NHibernate, working with interfaces

Programming to interfaces while mapping with Fluent NHibernate

and that let me fix the References issue, but I haven't found a work around for the KeyReference. Is there something obvious I'm missing, cause I've been googling around for awhile, and so far haven't been able to find anything.

Community
  • 1
  • 1
Zipper
  • 7,034
  • 8
  • 49
  • 66

1 Answers1

0

this maybe works

.KeyReference(x => x.myFoo, attr => attr.Column("fooID").EntityName("bar1"))
Firo
  • 30,626
  • 4
  • 55
  • 94
  • Unfortunately I'm using an older version of fluent, I don't have any functions that match that signature. – Zipper Jan 06 '12 at 16:33
  • then you have to do reflection or extend your own version of FNH. I can post the code for reflection if needed. – Firo Jan 06 '12 at 18:11