Mapping Dictionary<int, MyObject>

84 views
Skip to first unread message

nordside

unread,
May 30, 2012, 4:59:02 PM5/30/12
to fluent-n...@googlegroups.com
Hi,

I found some information to map a dictionary in FNH - but nothings works for me. With this configuration I receive an "Could not determine type for: MyObject, ConsoleApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, for columns: NHibernate.Mapping.Column(Id)" exception:

I use
FluentNHibernate - 1.3.0.727
NHibernate - 3.3.0.4000

    public class MyObject
    {
        public virtual int Id { get; set; }

        public virtual string PropertyString { get; set; }
    }


    public class MyObjectMap : ClassMap<MyObject>
    {
        public MyObjectMap()
        {
            Id(x => x.Id);
            Map(x => x.PropertyString);
        }
    }

    public class BigObject
    {
        public virtual int Id { get; set; }

        public virtual string Name { get; set; }

        public virtual Dictionary<int, MyObject> DicMyObject { get; set; }
    }


    public class BigObjectMap : ClassMap<BigObject>
    {
        public BigObjectMap()
        {
            Id(x => x.Id);
            Map(x => x.Name);

            HasMany(x => x.DicMyObject)
                .AsMap<MyObject>(
                    index => index.Column("key").Type<int>(),
                    element => element.Column("Id").Type<MyObject>())
                .Inverse()
                .Not.LazyLoad().Table("mybigobjects");
        }
    }


I hope someone has an idea.
Thanks
nordside

mynkow

unread,
Jun 3, 2012, 11:50:13 AM6/3/12
to fluent-n...@googlegroups.com
Can you try to add KeyColumn after AsMap().KeyColumn(...)
Reply all
Reply to author
Forward
0 new messages