Hello,
i've started to use IList, but i can not get it to work. It's very
easy and I don't understand what's going wrong. Creating the database
with hbm2ddl works fine
I'm doing this:
var i = new Item();
var session = NHibernateHelper.GetCurrentSession();
i.Name = "foo";
i.Tags.Add("bar1");
i.Tags.Add("bar2");
session.SaveOrUpdate(i);
foreach (var s in i.Tags) {
Console.WriteLine(s);
}
The console shows me:
NHibernate: INSERT INTO Item (Name) VALUES (:p0); select lastval();:p0
= 'foo'
bar1
bar2
I can see that the tags are not inserted into the database, but I
don't know why.
Item.cs:
using System;
using System.Collections.Generic;
namespace WpfApplication1 {
internal class Item {
private int id;
private IList<String> tags = new List<String>();
public virtual String Name { get; set; }
public virtual IList<String> Tags {
get { return tags; }
set { tags = value; }
}
}
}
Item.hbm.xml:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
cascade="all">
<class name="WpfApplication1.Item, WpfApplication1" lazy="false" >
<id name="id" access="field">
<generator class="native" />
</id>
<property name="Name" />
<list name="Tags">
<key/>
<index/>
<element/>
</list>
</class>
</hibernate-mapping>
It would be really greate if anyone can tell me what's going wrong
here.
Thanks,
Patrick
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.