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
Creating Proxy Objects after the document has been converted to an entity.
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
  10 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
 
JT  
View profile  
 More options May 16 2012, 6:03 pm
From: JT <jth...@gmail.com>
Date: Wed, 16 May 2012 15:03:16 -0700 (PDT)
Local: Wed, May 16 2012 6:03 pm
Subject: Creating Proxy Objects after the document has been converted to an entity.

I am using StructureMap and Castle for DI/IoC/Proxy Objects. When
retrieving a document, I would like to generate a proxy on that object so I
can still utilize interceptors for things like INPC and Logging.
I implemented IDocumentConversionListener, and added the logic to create a
proxy object, but RavenDb is still handing back the non-proxied object.

public void DocumentToEntity(object entity, Raven.Json.Linq.RavenJObject
document, Raven.Json.Linq.RavenJObject metadata) {

var proxyModel = ProxyGenerator.CreateClassProxyWithTarget(
entity.GetType(),
new Type[] { typeof(INotifyPropertyChanged) },
entity,
ProxyGenerationOptions.Default,
new ModelInterceptor());

entity = proxyModel;

}

Is it not possible to manipulate the object in this listener? Or should I
just be doing this in a completely different place?

Thanks for your time,
JT


 
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 16 2012, 7:42 pm
From: "Oren Eini (Ayende Rahien)" <aye...@ayende.com>
Date: Thu, 17 May 2012 00:42:43 +0100
Local: Wed, May 16 2012 7:42 pm
Subject: Re: [RavenDB] Creating Proxy Objects after the document has been converted to an entity.

JT,
No, this isn't how you would do this.
You aren't replacing the entity that we hold.
If you want to do that, you need to go through the Json Serializer.
Here is the docs on how to do this:
http://james.newtonking.com/projects/json/help/CustomCreationConverte...


 
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.
JT  
View profile  
 More options May 16 2012, 9:00 pm
From: JT <jth...@gmail.com>
Date: Wed, 16 May 2012 18:00:39 -0700 (PDT)
Local: Wed, May 16 2012 9:00 pm
Subject: Re: Creating Proxy Objects after the document has been converted to an entity.

Having a hard time finding documentation on these listeners. Can you
explain what the benefit is to having the entity object being passed?
Trying to figure out why this would be exposed to me if it isn't the actual
'entity' that get's passed to me from RavenDb.


 
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 17 2012, 4:37 am
From: "Oren Eini (Ayende Rahien)" <aye...@ayende.com>
Date: Thu, 17 May 2012 09:37:00 +0100
Subject: Re: [RavenDB] Re: Creating Proxy Objects after the document has been converted to an entity.

This allows you to do things like set properties on the entity that comes
from the metadata.


 
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.
JT  
View profile  
 More options May 17 2012, 9:37 am
From: JT <jth...@gmail.com>
Date: Thu, 17 May 2012 06:37:56 -0700 (PDT)
Local: Thurs, May 17 2012 9:37 am
Subject: Re: Creating Proxy Objects after the document has been converted to an entity.

Ok thanks. I'm looking forward to more documentation on listeners. Or even
introducing some new listeners that will let you manipulate the actual
entity that gets casted to the domain object during a
session.Load<TheObject>(id);

I guess I'm a bit spoiled by NHibernate which gave us the ability to attach
our own interceptors to the proxied object being handed back.

As of right now, it looks like I have to proxy the object manually after
every query, but I'm going to look a bit deeper into the JsonSerializer &
play with the metadata coming back.


 
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.
Bryan Johns  
View profile  
 More options May 17 2012, 9:52 am
From: Bryan Johns <bjo...@greendragonweb.com>
Date: Thu, 17 May 2012 08:52:17 -0500
Local: Thurs, May 17 2012 9:52 am
Subject: Re: [RavenDB] Re: Creating Proxy Objects after the document has been converted to an entity.
I wonder if AutoMapper would help with what you're trying to do?

According to the AutoMapper.org website it is, "...built to solve a
deceptively complex problem - getting rid of code that mapped one
object to another."

Disclaimer:  I am not associated with, nor have I ever actually used AutoMapper.

--
Bryan Johns
K4GDW
http://www.greendragonweb.com

Do not meddle in the affairs of dragons, for you are crunchy and taste
good with ketchup.


 
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 17 2012, 9:52 am
From: "Oren Eini (Ayende Rahien)" <aye...@ayende.com>
Date: Thu, 17 May 2012 14:52:07 +0100
Local: Thurs, May 17 2012 9:52 am
Subject: Re: [RavenDB] Re: Creating Proxy Objects after the document has been converted to an entity.

You HAVE the ability to do that.
Here is how:

http://james.newtonking.com/projects/json/help/CustomCreationConverte...

You attach this behavior to the docStore.Conventison.CustomizeSerializer
event.


 
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.
JT  
View profile  
 More options May 17 2012, 10:18 am
From: JT <jth...@gmail.com>
Date: Thu, 17 May 2012 07:18:18 -0700 (PDT)
Local: Thurs, May 17 2012 10:18 am
Subject: Re: [RavenDB] Re: Creating Proxy Objects after the document has been converted to an entity.

Interesting project. The issue I am running into is needing to grab and
manipulate my object before the query returns it to the UI/Webservice, etc..

So I would still run into this scenario using something like AutoMapper


 
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.
JT  
View profile  
 More options May 17 2012, 10:20 am
From: JT <jth...@gmail.com>
Date: Thu, 17 May 2012 07:20:03 -0700 (PDT)
Local: Thurs, May 17 2012 10:20 am
Subject: Re: [RavenDB] Re: Creating Proxy Objects after the document has been converted to an entity.

Thanks, the  docStore.Conventison.CustomizeSerializer  is what I was having
a hard time finding.

Will play with that now.


 
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.
JT  
View profile  
 More options May 17 2012, 11:49 am
From: JT <jth...@gmail.com>
Date: Thu, 17 May 2012 08:49:08 -0700 (PDT)
Local: Thurs, May 17 2012 11:49 am
Subject: Re: [RavenDB] Re: Creating Proxy Objects after the document has been converted to an entity.

Well, after learning a LOT more about the JSON library and following your
advice I figured it out!

You saved me once again Oren!


 
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 »