Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do you need webservices to access a database from Silverlight?

I am at the moment looking into several options to create a new app which can be accessed using the browser by multiple user in a closed intranet.

I thought about using Silverlight for its user-friendliness and its WPF design so close to the rich clients the future users are used to.

The project (of course) requires access to a database also within the intranet, hence I browsed the internet to see how data access was handled. I was surprised to see that you apparently have to use web services to interact with data, as mentioned in this SO post which points this tutorial (one of many ways to use webservices).

Having already created various rich client within an intranet all interacting with database, I was surprised to be forced to use web services.

Indeed, I do understand the advantages of the web services; the security it provides, and all the other features of created a good DAL generally in software architecture. However, I can't see why you can't simply create (for example) a library containing the Linq to SQL classes and use this library as reference in the silverlight project to access data directly as you can do with classic rich client application. I understand that by doing that, you store the access data within the connection string of the app, but I can't see why it shouldn't work with a silverlight client.

UPDATE:

So, two questions:

  1. Do we actually have to access data through web services?
  2. If so, why is it different from the classic rich client approach?
  3. Will Silverlight 5 enable me to do such thing?
like image 465
SRKX Avatar asked Feb 04 '26 13:02

SRKX


1 Answers

However, I can't see why you can't simply create (for example) a library containing the Linq to SQL classes and use this library as reference in the silverlight project to access data directly as you can do with classic rich client application.

Silverlight, unlike WPF, doesn't use or have access to the full .NET Framework. It's running under it's own, restricted CLR and framework.

In the decision of what to include and what to omit, it was decided that all of the data access components were left out of Silverlight. This really makes it impossible to directly create the "library using SQL" as mentioned above.

By using WebServices (or WCF, which is really the preferred method), you are only required to be able to create and access the service references, which is supported in Silverlight.

like image 61
Reed Copsey Avatar answered Feb 06 '26 03:02

Reed Copsey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!