views:

112

answers:

1

I am really confused about when to use WCF and when to use ADO data services in my website ajax calls.

I always make my javascript code call a webservice to get data from server "ajax".

But while reading in both WCF and ADO data service, i am not sure when to use each and when not use?, and if they replace each other in my case? or can live side by side?

Can anyone make me understand in points when to use which in ajax websites?

+1  A: 

ADO.net Data Services is a library to expose a datasource thru Wcf. As such the functionality exposed by an Ado.net Data Service is for reading, updating, creating and deleting records in that DataSource.

With Wcf you can expose any kind of functionality (that's why an ADO.net Data Service is a WCF service)

So to answer your question, if your client application needs direct access to the datasource then Ado.net Data Services will provide that functionality out of the box. If the client needs to talk to a Business Layer which in turn will access that Data Access Layer then you will expose that Business Layer as Wcf Services.

You could well use both approaches in the same application:

  • Exposing some tables directly using ADO.net Data Services
  • Exposing Business Logic with a WCF service

In a banking application for example you would not expose the Account table because you want to enforce some business rules. In a simple ToDo list application you could expose the Tasks table using ADO.net data services because there is no business logic to be applied (note that I said SIMPLE ToDo list app)

Guillaume Gros
But as i read, that ADO.net Data Services can attach to objects, not just datasources, and sure these objects can hold their logic, in this case it can replace WCF?
Amr ElGarhy