fluent-nhibernate icon indicating copy to clipboard operation
fluent-nhibernate copied to clipboard

Support Fake Relationships

Open ckalan opened this issue 12 years ago • 2 comments

I'm an Orchard developer and in Orchard, AutoMapping can add dynamic fake relationships because of the old Fluent API. In the latest version of FluentNhibernate, "References" methods require expressions which prevents creating dynamic relationships.

Say for instance, in Orchard there is a "ContentItemRecord" class , and each module creates a "PartRecord" table. Then Orchard creates dynamic ManyToOne references on ContentItemRecord for each PartRecord mapped by each module.

This may indeed be a requirement for many modular projects. I've added a new "References" method on the ClasslikeMapBase<T> class which gets a propertyName as a string parameters and calls the "ManyToOnePart<TOther> References<TOther>(Member member, string columnName)" method using a DummyPropertyInfo instance.

I've achieved migrating Orchard to FluentNHibernate's latest release with this but I'm not sure this is the right place to make this change.

ckalan avatar Jul 27 '12 12:07 ckalan

@ckalan Could you supply a pull request with your changes? What you've done sounds correct, we do something similar to support pseudo-ids.

jagregory avatar Aug 14 '12 06:08 jagregory

if someone is interested I found another workaround which does the same

public FooMap()
{
    Map(x => FakeProperty);
}

private int FakeProperty { get; set; }

firo222 avatar Dec 06 '12 04:12 firo222