persistent entitie
public partial class AR
{
public virtual string IdA { get; set; }
public virtual string IdA2 { get; set; }
public virtual string A1 { get; set; }
public virtual string A2 { get; set; }
public virtual char A3 { get; set; }
public override int GetHashCode()
{
return this.IdA.GetHashCode() + this.IdA2.GetHashCode();
}
public override bool Equals(object obj)
{
return base.Equals(obj);
}
maping class
public class MapeoA: ClassMap<AR>
{
public MapeoA()
{
CompositeId().KeyProperty(x => x.IdA, "ID_A")
.KeyProperty(x => x.IdA2, "ID_A2");
Map(x => x.A1).Column("A1").Length(11);
Map(x => x.A2).Column("A2").Length(8);
Map(x => x.A3).Column("A3").Length(1);
}
}
if one of the fields that are part of the composite key is a reference
to another class:
public partial class BR
{
public virtual string IdB { get; set; }
public virtual string B1 { get; set; }
public virtual string B2 { get; set; }
}
public partial class AR
{
public virtual string IdA { get; set; }
public virtual BR br { get; set; } <---------------------------------
public virtual string A1 { get; set; }
public virtual string A2 { get; set; }
public virtual char A3 { get; set; }
public override int GetHashCode()
{
return this.IdA.GetHashCode() + this.br.GetHashCode();
}
public override bool Equals(object obj)
{
return base.Equals(obj);
}
public class MapeoA: ClassMap<AR>
{
public MapeoA()
{
CompositeId().KeyProperty(x => x.IdA, "ID_A")
.KeyReferences(x => x.br, "ID_A2"); <-------------------
Map(x => x.A1).Column("A1").Length(11);
Map(x => x.A2).Column("A2").Length(8);
Map(x => x.A3).Column("A3").Length(1);
}
}
2011/5/27, TigerShark <kenneth...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups
> "Fluent NHibernate" group.
> To post to this group, send email to fluent-n...@googlegroups.com.
> To unsubscribe from this group, send email to
> fluent-nhibern...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/fluent-nhibernate?hl=en.
>
>