Inheritance Trouble

5 views
Skip to first unread message

Argons

unread,
Dec 14, 2009, 11:17:46 AM12/14/09
to Fluent NHibernate
Well, first of all sorry for my english.

This is my problem, I have an assembly with some classes like User,
Role, etc. these are generic clases for all my applications so I need
to inherit from these classes for each of my app's and add custom
properties like this:

public class User
{
public int IdUser { get; set;}
public string Login { get; set; }
public string Password { get; set; }

public Role ObjRole { get; set; }
}

public class SpecificUser : User
{
public DateTime LastLogin { get; set; }
public string Type { get; set; }
...
}

SpecificUser is in another assembly and I try to map like this:

public class SpecificUserMap : SubclassMap<User>
{
public SpecificUserMap()
{
KeyColumn("IdUser");
Map(x => x.LastLogin).Not.Nullable();
Map(x => x.Type).Not.Nullable();
...
}
}

But when I try to generate the schema it doesn't generate the table
SpecifiUser. Am I doing something wrong? How can I do the mapping?

Thanks in advance for the help.

Ariel.

James Gregory

unread,
Dec 14, 2009, 11:30:57 AM12/14/09
to fluent-n...@googlegroups.com
public class SpecificUserMap : SubclassMap<User>

should be

public class SpecificUserMap : SubclassMap<SpecificUser>
> --
>
> 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.
>
>
>

Argons

unread,
Dec 15, 2009, 7:01:17 AM12/15/09
to Fluent NHibernate
Yes, little error, I have changed to SpecificUser, but with the same
result, when I want to generate the schema none of the tables are
generated.
> >http://groups.google.com/group/fluent-nhibernate?hl=en.- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -

James Gregory

unread,
Dec 15, 2009, 7:09:42 AM12/15/09
to fluent-n...@googlegroups.com
How are you generating the schema? Can you show us the code you're using.

Argons

unread,
Dec 15, 2009, 8:01:21 AM12/15/09
to Fluent NHibernate
Sure, here's my code:

IPersistenceConfigurer database =
MsSqlConfiguration.MsSql2005.ConnectionString("MyConnectionString");
Configuration configNH = new Configuration();

Fluently.Configure(configNH)
.Database(database)
.Mappings(
m => m.FluentMappings.AddFromAssembly
(MySpecificAssembly)
.ExportTo(txtPath.Text))
.ExposeConfiguration(
c => new SchemaExport(c).SetOutputFile
(txtPath.Text + "\\script.sql").Execute
(false, true, false))
.BuildSessionFactory();

When I run this code no errors are thrown, and the same routine works
for other mappings,
but the error is when the inheritance is from another assembly, like I
explain before.

Thanks for any help.
> > > > fluent-nhibern...@googlegroups.com<fluent-nhibernate%2Bunsubscr­i...@googlegroups.com>
> > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/fluent-nhibernate?hl=en.-Ocultar texto
> > de la cita -
>
> > > - Mostrar texto de la cita -
>
> > --
>
> > 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<fluent-nhibernate%2Bunsubscr­i...@googlegroups.com>
> > .

James Gregory

unread,
Dec 15, 2009, 8:06:26 AM12/15/09
to fluent-n...@googlegroups.com
I missed the part about you having multiple assemblies.

Change your mappings call to this:

.Mappings(m =>
    m.FluentMappings
        .AddFromAssembly(MySpecificAssembly)
        .AddFromAssembly(MySecondAssemly)
        .ExportTo(txtPath.Text))

Where MySecondAssembly is the assembly that contains your SpecificUserMap.

To unsubscribe from this group, send email to fluent-nhibern...@googlegroups.com.

Argons

unread,
Dec 15, 2009, 10:20:27 AM12/15/09
to Fluent NHibernate
Thanks for the reply. I added the assembly of the base mapping clasess
and the assembly with the specific mappings (like James specified in
the previous post), this time it generates all the base classes (User,
Role, etc.) but still the SpecificUser is not generated.

Any light on this?

Argons

unread,
Dec 16, 2009, 8:38:37 AM12/16/09
to Fluent NHibernate
Still no luck. I'm stuck with this problem.
> > - Mostrar texto de la cita -- Ocultar texto de la cita -

Argons

unread,
Dec 17, 2009, 10:05:12 AM12/17/09
to Fluent NHibernate
Anyone please, help

James Gregory

unread,
Dec 17, 2009, 10:08:16 AM12/17/09
to fluent-n...@googlegroups.com
Please try to recreate your issue in an isolated solution and attach it here, we'll debug it.

To unsubscribe from this group, send email to fluent-nhibern...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages