I wrote a blog post on it:
http://dionscher.wordpress.com/how-to-map-a-nhibernate-map-tag-in-fluentnhibernate/
Hope it helps.
Group: http://groups.google.com/group/fluent-nhibernate/topics
- Mapping Dictionary<int, MyObject> [1 Update]
nordside <matthias...@googlemail.com> May 30 01:59PM -0700
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
You received this message because you are subscribed to the Google Group fluent-nhibernate.
--
You can post via email.
To unsubscribe from this group, send an empty message.
For more options, visit this group.
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.
public Customer() { Settings = new Dictionary(); // it is necessary to specify type for key and value }
In this way I specify an enumeration for the key
public enum SettingType
{
PrivateSetting,
PublicSetting
}
and a class for the value
public class Setting
{
public virtual string Setting1 { get; set; }
public virtual int Setting2 { get; set; }
}
At the end I modify the constructor
public Customer()
{
Settings = new Dictionary<SettingType, Setting>();
}
Now the question: how to map this? I try out several solutions i found in groups, blogs etc.
HasMany<Dictionary<SettingType, Setting>>(x => x.Settings).AsEntityMap();
HasMany(x => x.Settings)
.Component(c =>
{
c.Map(x => x.Setting1);
c.Map(x => x.Setting2);
});
HasMany<Setting>(x => x.Settings)
.AsEntityMap()
.Not.LazyLoad()
.Inverse()
.Cascade.AllDeleteOrphan();
Have you got an hint to help me?
Thanks
nordside
I wrote a blog post on it:
http://dionscher.wordpress.com/how-to-map-a-nhibernate-map-tag-in-fluentnhibernate/
Hope it helps.
On May 31, 2012 11:47 AM, <fluent-nhibernate@googlegroups.com> wrote:
To post to this group, send email to fluent-nhibernate@googlegroups.com.
To unsubscribe from this group, send email to fluent-nhibernate+unsubscribe@googlegroups.com.