The error i'm getting is: System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: The type SectorProxy was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.
I don't want to use DTO's since i feel it's just overhead which brings more work when it comes to maintenance, at the moment i'm simple taking the filled proxy classes and use those to create new representations of the actual classes the serializer expects and thus replace the proxy. Basically the lazy load properties (which sometimes don't need to be fetched which is why i dont just tell em all lazy="false") get loaded properly, but then the serializer choaks because it's not expecting SectorProxy, but it's expecting an instance of Sector instead. Obivously taking the proxy's and then creating new instances is a valid solution to keep the lazy loading without having to use DTO's, but somehow it's not as "pretty" of a solution as i'd like :) On 18 mrt, 11:20, John Rayner <[email protected]> wrote: > Best approach here is probably to map your entities into DTOs for > serialization. > > WCF (i.e. the DataContractSerializer) is able to neatly handle > serializing proxies ... I haven't attempted using the XmlSerializer > against a proxy. What error are you getting? > > Cheers, > John > > On Mar 17, 2:40 pm, "F.B. ten Kate" <[email protected]> wrote: > > > Hello nhusers, > > > I've been working with NHibernate a few months now and am starting to > > get the hang of things. Currently i'm running into a snag though. I'm > > returning object graphs from webservices, so far so good right? > > > I've gotten around the circulair reference problem by using > > ShouldSerialize{FOO} patterns in different classes (not ideal but i'm > > not allowed to use anything above .NET 2.0 so WCF isn't allowed >.<) > > > Current problem i'm attempting to tackle is Proxy Classes, since the > > graphs are rather large i want most of my properties to be lazy loaded > > (simply because users can enable/disable properties when calling the > > webservices). I'm not allowed to use lazy loading on properties though > > (i am allowed on collections) because webservices don't expect they > > need to serialize Proxy objects. > > > Even if i Initialize the properties using > > NHibernate.NHibernateUtil.Initialize() they are still thought of as > > Proxy object. > > > Is the any best practise to handle this problem? > > > Greetings, > > > Folkert -- 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.
