views:

24

answers:

2

Following on from this question, would it be a wise idea to place a WCF service at the server side, between client and database to handle queries?

The idea being that you take load of the network and reduce round trips to and from a database.

I would use the Entity Framework to query the database in the service, and just send results to requesting apps over the network.

I wondered if this is a silly or good idea?

There would be up to 10 clients and 1 server. Lots of queries requesting a few 1000 records at times, requiring quite a bit of calculations applied to them at times.

+2  A: 

I think it wouldn't be as efficient simply because of the protocols, wcf will require a lot more bytes to sand things back and forth than the native sql server protocol.

Otávio Décio
+1  A: 

Well, seems like a really smart idea at first.

But what are you going to return then?? A WCF contract needs to be very specific about its return values - you need to tell it whether it'll be a list of customers, or a single order with its order details etc.

Trying to get this to work generally, for any kind of SQL or EF / Entity-SQL query you want to have executed, might just be too tricky. You would almost have to "dumb it down" to a List<object> or List<BaseBusinessClass> something for it to work in a very generic way.

marc_s
@marc_s I'm interested in what you mean with 'repositories'... can you elaborate? So, you wouldn't use a service or only for very specific things?
Tony
@TOny: Repository as in the Repository pattern defined by Martin Fowler; see this link here http://weblogs.asp.net/fredriknormen/archive/2008/04/24/what-purpose-does-the-repository-pattern-have.aspx or search Google or Bing for "Repository Pattern" - you'll get tons of hits
marc_s
@Tony: I'm just not sure how much sense it makes to try and come up with a "generic all-purpose" WCF service that should be able to query for everything and the kitchen sink. I prefer to have my services be specific: a CustomerService, a LoginService, a ProductService etc. - makes things a lot easier, IMHO
marc_s
Thanks @marc_s! Useful and sensible advice! :)
Tony