I think it would be helpful if you could export the generated xml and post
it.

If you're not familiar with this process, its really quite easy. Here is an
example:

                .Mappings(m =>
                {
                    m.FluentMappings.AddFromAssemblyOf<Program>();

 m.FluentMappings.Conventions.AddFromAssemblyOf<Program>();

 m.FluentMappings.PersistenceModel.Conventions.Add(DefaultLazy.Never());
                    m.FluentMappings.ExportTo("mappings"); <---- SEE HERE
                })

On Thu, Feb 18, 2010 at 11:17 AM, leon251280 <leon251...@gmail.com> wrote:

> I'm using Fluent Nhibernate and i have this exception "Could not
> resolve property MailHeader of class MailHeader".
> There is no property MailHeader in the class MailHeader,  can you help
> me please? Thanks in advance
>
> The entities are:
>
>    public class User : Entity
>    {
>        public User()
>        {
>            MailHeaderRecipients = new List<MailHeader>();
>            MailsDeleted = new List<MailHeader>();
>        }
>
>
>        public virtual IList<MailHeader> MailHeaderRecipients { get;
> set; }
>        public virtual IList<MailHeader> MailsDeleted { get; set; }
>    }
>
>
>    public class Mail : Entity
>    {
>        public Mail()
>        {
>            MailHeader = new MailHeader();
>        }
>
>        [Required]
>        public virtual string BodyText { get; set; }
>        [Required]
>        public virtual MailHeader MailHeader { get; set; }
>
>        public virtual Mail Parent { get; set; }
>
>        [Required]
>        public virtual User From { get; set; }
>
>
>        public virtual Mail Child { get; set; }
>
>        [DataType(DataType.Date)]
>        public virtual DateTime Creation { get; set; }
>    }
>
>
>    public class MailHeader : Entity
>    {
>        public MailHeader()
>        {
>            MailRecipientUsers = new List<User>();
>            MailsDeleted = new List<User>();
>
>        }
>
>        [Required]
>        public virtual string Subject { get; set; }
>        public virtual IList<User> MailRecipientUsers { get; set; }
>        public virtual IList<User> MailsDeleted { get; set; }
>
>    }
>
>
> The mapping:
>
>    public class UserMap : IAutoMappingOverride<User>
>    {
>        public void Override(AutoMap<User> mapping)
>        {
>
>            mapping.HasManyToMany(x => x.MailHeaderRecipients)
>                .Inverse()
>         .WithTableName("MailRecipientUser")
>         .WithParentKeyColumn("[User]")
>         .WithChildKeyColumn("[MailHeader]")
>         .Cascade.All();
>
>            mapping.HasManyToMany(x => x.MailsDeleted)
>                .Inverse()
>         .WithTableName("MailDeleted")
>         .WithParentKeyColumn("[User]")
>         .WithChildKeyColumn("[MailHeader]")
>         .Cascade.All();
>
>        }
>    }
>
>
>    public class MailMap : IAutoMappingOverride<Mail>
>    {
>        public void Override(AutoMap<Mail> mapping)
>        {
>            mapping.References(x => x.From);
>            mapping.References(x => x.Parent);
>            mapping.References(x => x.MailHeader);
>
>            mapping.HasOne(e => e.Child)
>                .WithForeignKey()
>                .PropertyRef(a => a.Parent)
>                .Cascade.All();
>        }
>    }
>
>
>    public class MailHeaderMap : IAutoMappingOverride<MailHeader>
>    {
>        public void Override(AutoMap<MailHeader> mapping)
>        {
>            mapping.HasManyToMany(x => x.MailRecipientUsers)
>         .WithTableName("MailRecipientUser")
>         .WithParentKeyColumn("[MailHeader]")
>         .WithChildKeyColumn("[User]")
>         .Cascade.All();
>
>            mapping.HasManyToMany(x => x.MailsDeleted)
>         .WithTableName("MailDeleted")
>         .WithParentKeyColumn("[MailHeader]")
>         .WithChildKeyColumn("[User]")
>         .Cascade.All();
> }
>
>
> The ManyToMany tables are:
>
> CREATE TABLE [MailDeleted](
>          [MailHeader] int not null,
>          [User] int not null
> )
> go
> alter table [MailDeleted] add CONSTRAINT fk_MailDeleted_MailHeader
> FOREIGN KEY([MailHeader]) references [MailHeader] (Id)
> go
> alter table [MailDeleted] add CONSTRAINT fk_MailDeleted_User  FOREIGN
> KEY([User]) references [User] (Id)
> go
>
>
> CREATE TABLE [MailRecipientUser](
>          [MailHeader] int not null,
>          [User] int not null
> )
> go
> alter table [MailRecipientUser] add CONSTRAINT
> fk_MailRecipientUser_MailHeader  FOREIGN KEY([MailHeader]) references
> [MailHeader] (Id)
> go
> alter table [MailRecipientUser] add CONSTRAINT
> fk_MailRecipientUser_User  FOREIGN KEY([User]) references [User] (Id)
> go
>
> --
> You received this message because you are subscribed to the Google Groups
> "Fluent NHibernate" group.
> To post to this group, send email to fluent-nhibern...@googlegroups.com.
> To unsubscribe from this group, send email to
> fluent-nhibernate+unsubscr...@googlegroups.com<fluent-nhibernate%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/fluent-nhibernate?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibern...@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.

Reply via email to