How can I rebuild the Hibernate DAO layer of an ASP.NET application to move it to Silverlight?

Try to get an answer to this question.

I have a simple ASP.NET application that uses Hibernate to access data. The GUI can call methods on the Customer object, such as "CalculateTotalSumOfOrders ()". Lazy loading will work for me (although not optimal), and when domain objects are referenced by the Orders and OrderLines collections, they are automatically fetched from the database.

Now let's assume that I am rewriting the same application in Silverlight because it looks better than ASP.NET. I can NEVER perform lazy loading or data access because the Silverlight client is running in a browser. How can I solve this problem without having to think about what service to use to get data in the Silverlight client?

0


source to share


4 answers


The best way to support all of these platforms is by using a web service. There are many different options you can choose from: .NET 2.0 Web Services (ASMX), WCF, REST, if you are using Silverlight you may need to use WCF + LINQ to SQL, which is demonstrated here . This combination can also be used in ASP.NET (if running on .NET 3.5) and Windows Desktop Apps (again .NET 3.5).



You might also be interested in the open source project InterLinq, basically it allows you to create LINQ to SQL queries on the client side and then pass them through WCF to the server, which executes the query and returns the result. It can be found here . I've experimented with it in the past and it works well.

+1


source


One option to support Silverlight and Windows clients will be the new ADO.NET Data Services in .NET 3.5 SP1. It is a set of services that expose your database schema through a WCF interface. Then you can retrieve data from Silverlight or Windows client using WCF client.



As @McWafflestix said, you won't be able to do lazy loading anymore, but that's a good thing in my opinion because fetching data is now much more "expensive".

+1


source


Are you trying to take a server application that interacts with your database and does lazy loading, and converts it to a client application without much work? Sorry, it just won't work. What you need is a major rebuild of your application.

Unfortunately...

0


source


*

"That's good because I'm pretty early there. How would you handle it to support ASP.NET, Silverlight, and Windows clients with minimal overhead?"

*

I know I have been answering this question in the past, anyway. I would suggest that you use the MVP design pattern; this will help you create multiple "views" to work with your model. To provide support for Windows clients, you will need to expose your business layer using the service layer (see WCF).

0


source







All Articles