views:

1405

answers:

4

I have an ASP.NET 3.5 e-commerce site that has an admin section. I want to swap out the ASP.NET-based admin section and rewrite it in Silverlight 2. Silverlight requires async calls, so I can't just call my existing DAL from a new SL2 app.

What is the best practice for doing something like this? Should I create a WCF service and call my existing DAL through that, or should I port everything to WCF, or should I just add async calls into my existing, non-WCF DAL. Looking for advice on the best way to do something like this.

EDIT: So what I'm reading is that the best way to do this is to leverage my existing DAL and create a simple WCF service that references that DAL and wraps the calls. The WCF service does nothing more than act as a middleman to get to my DAL, but expose it to Silverlight. What if you're starting from scratch? Should you build out your DAL as a WCF service to begin with and use that service from a WPF client, ASP.NET client, Silverlight client, any other consumer, etc.

+5  A: 

If you need your DAL in multiple places I would suggest that you wrap it in a WCF service layer.

It will depend on your DAL but try your best to wrap the existing code in a service layer rather than re-writing everything as a service. This will give you maximum flexibility for testing and future scalability.

Andrew Hare
+6  A: 

You generally want to avoid putting data access code into a Silverlight application, because the user can easily reverse-engineer your code. In fact, the Silverlight runtime does not include any database communication framework classes for this very reason.

The recommended best practice is to wrap your Data Access Layer with a WCF service and call the WCF service from Silverlight. There's a good article on doing this here.

davogones
A: 

Certainly if you are creating DAL from scratch WCF service is the good choice that was available. But I think now .NET RIA service would be better choice in such scenarios. .Net RIA service is wrapper to WCF service only. But allows better features.

Manoj
A: 

RIA Services is the best option nowdays. The other non-WCF way (WCF Data access is so hard to maintain in large scale LOB applications in silverlight) could be a RESTful way to exchange data between server and client.

Aggelos Mpimpoudis