I'm trying to use Net4Collections to enable .net 4 ISet<T> in my
domain. Everything works beautifully except ISession.Merge, which I
need to update objects which have been passed between service tiers.
I've created the following test which will break in the published
bitbucket project (https://bitbucket.org/jfromaniello/
nhibernate.setfornet4). It throws {"Unable to cast object of type
'NHibernateSetForNet4.PersistentGenericSet`1[NHibernateSetForNet4.Person]'
to type 'Iesi.Collections.ISet'."} on the merge call. Any ideas
greatly appreciated. Regards, Asher
[Test]
public void CanEvictAndMergePerson()
{
UpdatePerson();
VerifyUpdate();
}
private void UpdatePerson()
{
using (var s = sessionFactory.OpenSession())
using (var tx = s.BeginTransaction())
{
var person = s.Get<Person>(personId);
var child = person.Childs
.First(c => c.Name == "Francisco");
s.Evict(person); //let's say we pass the object to
another tier..
child.Name = "Frank"; //make some changes
s.Merge(person); //pass it back to the repo and
merge...
tx.Commit();
}
}
private void VerifyUpdate()
{
using (var s = sessionFactory.OpenSession())
using (s.BeginTransaction())
{
var person = s.Get<Person>(personId);
var child = person.Childs
.First(c => c.Name == "Frank");
child.Should().Not.Be.Null();
child.Name.Should().Be("Frank");
}
}
--
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.