could you give me an example of configuring JSON.net to work correctly
in this scenario?

btw. thnx for your answer! :)


Vladan

On 28 sij, 15:42, "[email protected]" <[email protected]>
wrote:
> You are correct in thinking that the problem you are having is because
> of the lazy loading situation (proxies).
> The JavaScriptSerializer that MVC uses by default is a very unflexible
> piece of code and does not work well in these scenarios.  I would
> suggest not using it at all.
> I got around this by using JSON.NET and creating a custom action
> result.
>
> On Jan 28, 9:36 am, Vladan Strigo <[email protected]> wrote:
>
> > ...doesn't work. It says there are circular references, when in fact
> > there are none.
>
> > Here is my model:
>
> >     public class Product : Entity
> >     {
> >         public virtual string Name { get; set; }
> >     }
>
> >     public class Prospect : Entity
> >     {
> >         public virtual string Sex { get; set; }
> >         public virtual string Initials { get; set; }
> >         public virtual string LastName { get; set; }
> >         public virtual int HouseNo { get; set; }
> >         public virtual Product Product { get; set; }
> >     }
>
> > As you can see, its a simple one.
>
> > When using the JS Serializer on it:
>
> > var serialize = (new JavaScriptSerializer()).Serialize(list);
>
> > it brakes with "A circular reference was detected while serializing an
> > object of type "System.Reflection.Module""
>
> > As soon as I slim down my model to exclude "Product" entity from being
> > mapped (so that its a normal child entity), it works ok.
>
> > The best thing I can conclude is that its because of Castle's proxy's.
>
> > Did anyone tackle this problem? I've seen solutions for JSON.Net, but
> > as the application on which I am working is working with built in MS
> > MVC action results (one of them being Json action result)...it
> > automatically uses that for serialization.
>
> > Any ideas?
>
> > Vladan

-- 
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.

Reply via email to