Reputation: 14713
I have a one-to-one relationship in my database, and I'd like to just combine that into one object in Fluent NHibernate. The specific tables I am talking about are the aspnet_Users and aspnet_Membership tables from the default ASP.NET Membership implementation. I'd like to combine those into one simple User object and only get the fields I want.
I would also like to make this read-only, as I want to use the built-in ASP.NET Membership API to modify. I simply want to take advantage of lazy-loading.
Any help would be appreciated. Thanks!
Upvotes: 0
Views: 200
Reputation: 14713
Here's my completed mapping:
public class UserMap : ClassMap<User>
{
public UserMap()
{
Table("aspnet_Membership");
Id(x => x.ID, "UserId");
Map(x => x.EmailAddress, "Email");
Join("aspnet_Users", m =>
{
m.KeyColumn("UserId");
m.Map(x => x.UserName);
});
}
}
Upvotes: 0
Reputation: 5083
How about using the Join
method of Fluent NHibernate to join the tables in your mapping. See James Gregory's answer in this question.
Upvotes: 1