That's interesting John... So you are loading the entities when you
send them to the client AND when you want to save them. Is it still
efficient ? And I take it as you don't use DTO's then ?

On 8 avr, 15:13, John Rayner <john.ray...@conchango.com> wrote:
> So that's the default WCF behaviour - to deserialize a collection of
> objects into an array.  You can control this by either tweaking the
> WCF proxy generation (using command line parameters to whatever it is
> that generates the proxies) or you can supply your own class for
> deserialization.
>
> And I'll agree with Greg here that updates using the Command pattern
> are probably easier and probably more reliable.  I've described this
> elsewhere before in this list, but my project uses serialization of
> entities just to get data to the client.  When we want to manipulate
> data, then we have some command objects that we post to the WCF
> service.  The updating service will then load entities from the NHib
> session, update them and then pass resulting state changes (e.g. an
> Identity value has been assigned) back over the wire to the client.
>
> Cheers,
> John
>
> On Apr 7, 3:07 pm, graphicsxp <graphic...@googlemail.com> wrote:
>
> > John > I know it looks weird but that's what I get. I think this post
> > illustrates exactly my issue 
> > :http://lunaverse.wordpress.com/2007/05/09/remoting-using-wcf-and-nhib...
> > Unfortunately I haven't been successful in implementing it :(
>
> > Greg>   send them to the domain as commands.
> > Do you mean SQLCommands ? As in not using NH to persist my entity  ?
>
> > On 7 avr, 14:59, Greg Young <gregoryyou...@gmail.com> wrote:
>
> > > Don't .. have the UI track the changes that the user wants to make and
> > > send them to the domain as 
> > > commands.http://martinfowler.com/eaaDev/EventSourcing.htmlisagood start.
>
> > > but even if you wanted a DTO up/down CRUD model just send back the DTO
> > > and map it back to your domain object.
>
> > > On Tue, Apr 7, 2009 at 4:43 AM, graphicsxp <graphic...@googlemail.com> 
> > > wrote:
>
> > > > Yes that's for the benefits of using DTO's, but I'm more concerned
> > > > with the drawbacks :p
>
> > > > How do I map my entities to my dto's, and when I send the dto back
> > > > from the client to the server, how to I recreate an entity with the
> > > > full data so that nhibernate can detect only the changes made by the
> > > > client ?
>
> > > > On 7 avr, 05:59, Davy Brion <ral...@davybrion.com> wrote:
> > > >> +1
>
> > > >> if you keep your entities within your service boundaries you avoid the 
> > > >> whole
> > > >> lazy-load/proxying issue, and you also have the ability to evolve your
> > > >> domain model without breaking clients.
>
> > > >> On Mon, Apr 6, 2009 at 7:07 PM, Greg Young <gregoryyou...@gmail.com> 
> > > >> wrote:
>
> > > >> > Not exposing entities on the wire is a best practice with any tool.
>
> > > >> > Even if you control both ends it is still in general a bad idea in 
> > > >> > all
> > > >> > but the most simplistic of examples.
>
> > > >> > Greg
>
> > > >> > On Mon, Apr 6, 2009 at 1:04 PM, Dotan N. <dip...@gmail.com> wrote:
> > > >> > > those best practices apply to entity framework or did MS build in 
> > > >> > > some
> > > >> > sort
> > > >> > > of transparent integration between EF and wcf?
>
> > > >> > > On Mon, Apr 6, 2009 at 6:37 PM, John Rayner 
> > > >> > > <john.ray...@conchango.com>
> > > >> > > wrote:
>
> > > >> > >> Please let everyone know how that works out for you.  Using NHib 
> > > >> > >> to
> > > >> > >> drive WCF services is of interest to many people and there are 
> > > >> > >> very
> > > >> > >> few clear best practices at the moment.
>
> > > >> > >> On Apr 6, 2:11 pm, graphicsxp <graphic...@googlemail.com> wrote:
> > > >> > >> > Hi John
>
> > > >> > >> > I tend to agree with you, although I can see the benefits of 
> > > >> > >> > using
> > > >> > >> > DTO's as well.  If go back to your first reply, you suggested 
> > > >> > >> > turning
> > > >> > >> > off lazy-loading in the mapping.
> > > >> > >> > I don't think it's a good idea because some of my clients won't 
> > > >> > >> > use
> > > >> > >> > WCF and could benefit from lazy-loading.  Therefore, how about 
> > > >> > >> > I turn
> > > >> > >> > on/off lazy loading at DAO level ? I could have some methods 
> > > >> > >> > which
> > > >> > >> > would request an entity using _session.get<myentity>(id) and 
> > > >> > >> > others
> > > >> > >> > (for WCF) that would make use of ICriteria  to join on the 
> > > >> > >> > dependent
> > > >> > >> > tables in order to load everything at once... It seems to be my
> > > >> > >> > favourite idea (at least until the next hour ;p )
>
> > > >> > >> > On 6 avr, 13:01, John Rayner <john.ray...@conchango.com> wrote:
>
> > > >> > >> > > This is good advice ... if you have WCF clients which are
> > > >> > externally-
> > > >> > >> > > controlled systems.  If you control both the service and its
> > > >> > consumer,
> > > >> > >> > > and you expect them to evolve in sync with each other, then I 
> > > >> > >> > > think
> > > >> > >> > > the choice is less clear.
>
> > > >> > >> > > On Apr 2, 4:06 pm, James Hicks <jhicks0...@gmail.com> wrote:
>
> > > >> > >> > > > Don't expose internal types to external systems.  Use coarse
> > > >> > grained
> > > >> > >> > > > messages and DTOs to model the external view of your 
> > > >> > >> > > > system.  The
> > > >> > >> > > > small
> > > >> > >> > > > price you pay in maintaining this extra layer buys you the 
> > > >> > >> > > > ability
> > > >> > >> > > > to change
> > > >> > >> > > > your internal system without affecting the clients of the 
> > > >> > >> > > > service.
>
> > > >> > >> > > > If you are insistent on exposing your entities via WCF, 
> > > >> > >> > > > turn off
> > > >> > >> > > > lazy
> > > >> > >> > > > loading.  You may be able to generate your own proxies that 
> > > >> > >> > > > are
> > > >> > >> > > > smart enough
> > > >> > >> > > > to go back to the WCF service to pull down any lazy loaded
> > > >> > >> > > > collections.
>
> > > >> > >> > > > James
>
> > > >> > >> > > > On Tue, Mar 31, 2009 at 12:08 PM, graphicsxp
> > > >> > >> > > > <graphic...@googlemail.com>wrote:
>
> > > >> > >> > > > > Hi,
>
> > > >> > >> > > > > I'm struggling to get WCF Service working with NHibernate.
>
> > > >> > >> > > > > I have a  Post entity which holds a collection of 
> > > >> > >> > > > > Publication
> > > >> > >> > > > > entities
> > > >> > >> > > > > (lazy loaded). When the collection is loaded and the Post 
> > > >> > >> > > > > entity
> > > >> > >> > > > > returned to the client via WCF, there is an exception :
>
> > > >> > >> > > > > Type 'PublicationProxyc00e5dcd4dce4ee889643285aadb5575' 
> > > >> > >> > > > > cannot
> > > >> > >> > > > > have
> > > >> > >> > > > > DataContractAttribute attribute Namespace set to null.
>
> > > >> > >> > > > > The type PublicationProxy was created by NHibernate but 
> > > >> > >> > > > > the
> > > >> > >> > > > > Publication class looks like :
>
> > > >> > >> > > > > [DataContract(Name = "Publication")]
> > > >> > >> > > > >  public class Publication : IPublication
> > > >> > >> > > > >  {
> > > >> > >> > > > >  .
> > > >> > >> > > > >  .
> > > >> > >> > > > >  .
> > > >> > >> > > > >  }
>
> > > >> > >> > > > > What can I do to workaround this issue ?- Hide quoted 
> > > >> > >> > > > > text -
>
> > > >> > >> > > > - Show quoted text -- Hide quoted text -
>
> > > >> > >> > - Show quoted text -
>
> > > >> > --
> > > >> > It is the mark of an educated mind to be able to entertain a thought
> > > >> > without accepting it.
>
> > > --
> > > It is the mark of an educated mind to be able to entertain a thought
> > > without accepting it.- Hide quoted text -
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to nhusers@googlegroups.com
To unsubscribe from this group, send email to 
nhusers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to