So I got a User class which contains
public virtual IList<Message> SendMessages { get; set; }
public virtual IList<Message> ReceiveMessage { get; set; }
and a fews other properties
and I got a Message class which have
public virtual User From { get; set; }
public virtual User To { get; set; }
public virtual string FromName { get; set; }
public virtual string ToName { get; set; }
public virtual string Subject { get; set; }
public virtual string Body { get; set; }
a User will have many SendMessages and Many RecieveMessages
so override the UserMapping as follow
public class UserMapping:IAutoMappingOverride<User>
{
public void Override(AutoMapping<User> mapping)
{
mapping.HasMany(x => x.SendMessages).KeyColumn("FromFk");
mapping.HasMany(x => x.ReceiveMessage).KeyColumn("ToFk");
}
}
my foreign key convention is as follow
protected override string GetKeyName(Member property, Type type)
{
if (property == null)
return type.Name + "Fk";
return property.Name + "Fk";
}
And everything work however I wonder if there is a fluent way with lamda to
do the mapping.HasMany so it will pick up my foreignkey convention
automatically?
something like mapping.HasMany(x,y => x.RecieveMessage to y.To) <-- this
doesn't work of course but is a strongtype version that will tell FNH to
connect
Message.RecieveMessage to User.To
I hope that make sense.
Best,
Hoang
--
You received this message because you are subscribed to the Google Groups
"Fluent NHibernate" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/fluent-nhibernate?hl=en.