nhibernate / fluent-nhibernate

Fluent NHibernate!
BSD 3-Clause "New" or "Revised" License
1.66k stars 687 forks source link

Support Fake Relationships #150

Open ckalan opened 12 years ago

ckalan commented 12 years ago

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 class which gets a propertyName as a string parameters and calls the "ManyToOnePart References(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.

jagregory commented 12 years ago

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

firo222 commented 11 years ago

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

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

private int FakeProperty { get; set; }