what should i use instead of referencesany ?

24 views
Skip to first unread message

MoD

unread,
Aug 24, 2011, 9:14:06 AM8/24/11
to Fluent NHibernate
I have a fluent mapping case and according to documentation the only
was i found is to use ReferencesAny().
But again according to documentation i need to use referencesany in
special cases.

Is there a way to achieve this without using referencesany() ?
(I trimmed down fields to make myself clear)

public BaseEntity()
{
public Id { get;set;}
...
}

public Folder() : BaseEntity....
public Contact() : BaseEntity ..
public Account() : BaseEntity ...

public SharingRecord()
{
public Id { get;set;}
public BaseEntity SharedEntity { get;set;}
public ShareLevel Level { get;set;}
public User User { get;set;}
...
}

Folder, Contact and Account are different tables. SharingRecord's
parent can be any of them.

Thanks in advance.

mynkow

unread,
Aug 29, 2011, 5:31:04 PM8/29/11
to fluent-n...@googlegroups.com
I was in this situation many times. In 99% I use 1 table with discriminator. If I fall to the 1% then I always think that something smells in my design. That is why I have only 1% with Any mapping. If you cant redesign your code or put your entities in 1 table then you can use Any mapping. Remember that you cannot use FK with Any.

Good luck
Reply all
Reply to author
Forward
0 new messages