views:

167

answers:

3

Hi All:

I am new to this group so apologies if this has already been answered (I have had a good look). I am having a look at sharp architecture for a project I'm soon to start out on.

I am experimenting with the Northwind sample, and wanted to test a self referential relationship, but discovered Fluent NHibernate 1.1 was needed (see http://support.fluentnhibernate.org/discussions/help/127-parentchild-...).

So I recompiled with version 1.1 of fluent and ran into a couple of problems with the Employee class. The first error was along the lines of FullName needs a get. I solved this with mapping.IgnoreProperty(x => x.FullName); in the EmployeeMap class.

The next issue I haven't managed to solve: Invalid column name 'Id'. I can see from the test output that NHibernate is trying to do "SELECT top 0 this_.Id " etc. However the EmployeeMap class maps it to EmployeeID, so would expect to see "SELECT top 0 this_.EmployeeID "

    mapping.Id(x => x.Id, "EmployeeID")
            .UnsavedValue(0)
            .GeneratedBy.Identity();

Any ideas?

Thanks ... Rich

A: 

Hi Rich,

I made similar changes to a demo project of my own as well as the Northwind project and didn't have a problem. Did you recompile the SharpArch.dll using the new FluentNHibernate.dll?

Regards
Dan

Dan
Hi Dan, yes, I recompiled the SharpArch.dll. I might just try deleting the whole thing and starting over.Cheers ... Rich
Rich Cleeve
A: 

Are you deriving your class mappings from ClassMap<>?

I've not worked with the S#, but our FnH1.1 mappings look like this:

public class EntityMap : ClassMap<Entity>
{

    public EntityMap ()
    {

        // Single table
        Table("EntityTable");

        // ID
        Id(x => x.Id, "EntityId")
            .GeneratedBy
            .HiLo("NHibernateHilo", "HighId", "1", "EntityId=1");

        // References
        References(x => x.Object, "ReferenceFieldId").Cascade.SaveUpdate();

        // Properties
        Map(x => x.PropertyName, "FieldName");

    }

}
Ryan Barrett
Hi Ryan, thanks for your reply, yes they are derived from ClassMap. I've not really looked at it much more, as we are going with something else now.
Rich Cleeve
A: 

Just for the record: I had the same problem and the problem for me was that I had added an extra Id property to my Employee class.

Ivar