Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Using a IDocumentStoreListener to modify the saved entity is failing with InvalidOperationException
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  11 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
marcus  
View profile  
 More options May 2 2012, 2:31 pm
From: marcus <mar...@meridium.se>
Date: Wed, 2 May 2012 11:31:09 -0700 (PDT)
Local: Wed, May 2 2012 2:31 pm
Subject: Using a IDocumentStoreListener to modify the saved entity is failing with InvalidOperationException

I need to update an entity before it's saved, to modify it I need to use
the documentsession and load another document and use it for calculating
the value I need to change. When I do that I get an
InvalidOperationException: Collection was modified; enumeration operation
may not execute

Is this a big no no? This is my sample code http://cl.ly/GJJq


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Itamar Syn-Hershko  
View profile  
 More options May 2 2012, 3:06 pm
From: Itamar Syn-Hershko <ita...@hibernatingrhinos.com>
Date: Wed, 2 May 2012 22:06:55 +0300
Local: Wed, May 2 2012 3:06 pm
Subject: Re: [RavenDB] Using a IDocumentStoreListener to modify the saved entity is failing with InvalidOperationException

It does look weird. What are you trying to do?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Oren Eini (Ayende Rahien)  
View profile  
 More options May 2 2012, 3:14 pm
From: "Oren Eini (Ayende Rahien)" <aye...@ayende.com>
Date: Wed, 2 May 2012 22:14:04 +0300
Local: Wed, May 2 2012 3:14 pm
Subject: Re: [RavenDB] Using a IDocumentStoreListener to modify the saved entity is failing with InvalidOperationException

You can't modify the session while you are inside the store listenwr


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
marcus  
View profile  
 More options May 2 2012, 3:39 pm
From: marcus <mar...@meridium.se>
Date: Wed, 2 May 2012 12:39:43 -0700 (PDT)
Local: Wed, May 2 2012 3:39 pm
Subject: Re: [RavenDB] Using a IDocumentStoreListener to modify the saved entity is failing with InvalidOperationException

Ok, I solved it by adding the stuff i needed to the parent. I think it will
work ok

Den onsdagen den 2:e maj 2012 kl. 21:14:04 UTC+2 skrev Oren Eini:

> You can't modify the session while you are inside the store listenwr

> On Wednesday, May 2, 2012, marcus wrote:

>> I need to update an entity before it's saved, to modify it I need to use
>> the documentsession and load another document and use it for calculating
>> the value I need to change. When I do that I get an
>> InvalidOperationException: Collection was modified; enumeration operation
>> may not execute

>> Is this a big no no? This is my sample code http://cl.ly/GJJq

Den onsdagen den 2:e maj 2012 kl. 21:14:04 UTC+2 skrev Oren Eini:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Marisic  
View profile  
 More options May 2 2012, 3:40 pm
From: Chris Marisic <ch...@marisic.com>
Date: Wed, 2 May 2012 12:40:26 -0700 (PDT)
Local: Wed, May 2 2012 3:40 pm
Subject: Re: [RavenDB] Using a IDocumentStoreListener to modify the saved entity is failing with InvalidOperationException

I found this fact to be total crap when I was working with NHibernate and
made NHibernate listeners entirely useless.

Why shouldn't you be able to load a document? I can understand not allowing
MODIFYING loaded documents inside the listener but I certainly don't see
why you can't get a copy of the document.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Marisic  
View profile  
 More options May 2 2012, 3:42 pm
From: Chris Marisic <ch...@marisic.com>
Date: Wed, 2 May 2012 12:42:49 -0700 (PDT)
Local: Wed, May 2 2012 3:42 pm
Subject: Re: Using a IDocumentStoreListener to modify the saved entity is failing with InvalidOperationException

Some thoughts on possible work arounds, try using lower level APIs:

Session.Advanced.DatabaseCommands.Get()

ABSOLUTE worst case, you could probably make a direct web request to the
server, the server would have no idea at that point.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Itamar Syn-Hershko  
View profile  
 More options May 2 2012, 6:09 pm
From: Itamar Syn-Hershko <ita...@hibernatingrhinos.com>
Date: Thu, 3 May 2012 01:09:30 +0300
Local: Wed, May 2 2012 6:09 pm
Subject: Re: [RavenDB] Using a IDocumentStoreListener to modify the saved entity is failing with InvalidOperationException

My personal take: this will encourage people to do stuff that is considered
bad practice with RavenDB. If you want some other doc available to you, use
Includes when you first loaded the original document, why issue 2 different
commands? Or better - make sure to take this into account when modeling


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt Warren  
View profile  
 More options May 2 2012, 6:10 pm
From: Matt Warren <mattd...@gmail.com>
Date: Wed, 2 May 2012 15:10:11 -0700 (PDT)
Local: Wed, May 2 2012 6:10 pm
Subject: Re: [RavenDB] Using a IDocumentStoreListener to modify the saved entity is failing with InvalidOperationException

On Wednesday, 2 May 2012 20:40:26 UTC+1, Chris Marisic wrote:

> I found this fact to be total crap when I was working with NHibernate and
> made NHibernate listeners entirely useless.

> Why shouldn't you be able to load a document? I can understand not
> allowing MODIFYING loaded documents inside the listener but I certainly
> don't see why you can't get a copy of the document.

But for this to work wouldn't you have to ask the session to load a doc,
but not track/cache it, otherwise it's always possible for it to be changed?

I guess you could use the low-level Advanced API's like you said in your
other reply. Or if there was some way of saying to the session, that you
want to load a doc, but don't track it, but I guess that's what the
low-level API is for.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Oren Eini (Ayende Rahien)  
View profile  
 More options May 3 2012, 5:22 am
From: "Oren Eini (Ayende Rahien)" <aye...@ayende.com>
Date: Thu, 3 May 2012 12:22:53 +0300
Local: Thurs, May 3 2012 5:22 am
Subject: Re: [RavenDB] Using a IDocumentStoreListener to modify the saved entity is failing with InvalidOperationException

I fixed this so this wouldn't throw, but it still had a lot of bad
implications.
For example, the newly loaded entity will not be part of the current Unit
of Work, so changes made to it won't be captured.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Marisic  
View profile  
 More options May 3 2012, 8:53 am
From: Chris Marisic <ch...@marisic.com>
Date: Thu, 3 May 2012 05:53:56 -0700 (PDT)
Local: Thurs, May 3 2012 8:53 am
Subject: Re: [RavenDB] Using a IDocumentStoreListener to modify the saved entity is failing with InvalidOperationException

The most primary use case for needing to load a document from the DB would
be to load  User Document so you could insert denormalized data into the
document you're saving.

On every system action I save the userid & username (denormalized, don't
really care if they change it later it makes it easier for a human to
understand if they look at history and see b...@site.com and not just
userid:234347). I created a custom authentication system that exists
outside of raven and allows me access to my full user object at all times,
without having that functionality I could very well want to load a user
document instead. (This was what I wanted to do in nhibernate but couldn't,
and is part of the reason I built my auth system as I did, and by build i
mean build on top of forms auth not roll my own entire security system)

Also I could see the use case similar to the OPs when working with
hierarchical data that a change to a child object could theoretically need
to change the parent object.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Itamar Syn-Hershko  
View profile  
 More options May 3 2012, 4:40 pm
From: Itamar Syn-Hershko <ita...@hibernatingrhinos.com>
Date: Thu, 3 May 2012 23:40:24 +0300
Local: Thurs, May 3 2012 4:40 pm
Subject: Re: [RavenDB] Using a IDocumentStoreListener to modify the saved entity is failing with InvalidOperationException

Chris, for both scenarios mentioned I can see an easier way out -

For storing user data, just have that user entity handy by using Includes
or saving the current user object in the HTTP session context

For hierarchical data, if changes made to a child document always affect
the parent, you might want to store a large document to hold the hierarchy
details instead of doing this within the entities themselves. Doing this,
especially if that is a common operation, violates the transactional
boundary


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »