Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Using DataContext with WCF services

Reply
 
Old 08-19-2008   #1 (permalink)
Ragesh Krishna


 
 

Using DataContext with WCF services

Hello,

I'm creating a WCF service in which I use LINQ to SQL to do all my data access.
I have a couple of architectural questions about using LINQ to SQL from WCF
services:

1) What is the right way to use DataContext in this scenario?

The service will obviously be used by multiple clients simultaneously. Should
I be creating a "global" DataContext object that I use from within each of
my WCF operations, or should I create a DataContext within each operation?
My guess is that a global DataContext object is the right approach, but in
this case, how would I ensure that when I call SubmitChanges it only submits
the changes requested by a specific client?

2) What is the right way to pass data to/from WCF operations?

Is it possible to return the entity classes from an operation? If it isn't
(which I'm guessing is true), then how do I use LINQ to SQL's conflict detection
and resolution? If my DataContext object is local to each operation, would
it be able to detect conflicts at all?



Thanks,
-- Ragesh Krishna.



My System SpecsSystem Spec
Old 08-21-2008   #2 (permalink)
Marc Gravell


 
 

Re: Using DataContext with WCF services

> Should I be creating a "global" DataContext object that I use from
Quote:

> within each of my WCF operations, or should I create a DataContext
> within each operation?
I would argue "local" - there are lots of issues otherwise, not least
thread safety.
Quote:

> 2) What is the right way to pass data to/from WCF operations?
> Is it possible to return the entity classes from an operation?
I don't really understand the question - perhaps re-phrase?

One common approach here is to keep both the original and new version
(at the client) - send them both up the wire and use the overload that
allows you to add them to the data-context; this enables change/conflict
detection.

Alternatively, look at ADO.NET Data Services (aka Astoria), which does
all this for you - i.e. it provides a client data-context that can talk
to your IQueryable<T> service over WCF.

Marc
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
WPF - Binding IsEnabled property doesnt evaluate until DataContext .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46