views:

60

answers:

2

Hello:

I developed WPF / XAML applications that invoke objects (functions or Web services) which retrieve data from various sources (SQL Server DB, Active Directory, Oracle DB, SAP RFC, XML files, flat files, etc.).

These objects always return Datasets, which then bind to datagrids for displaying information to the user, additionally I do interesting things with datasets (join tables, retrieve the metadata/structure, create new columns, etc).

Because WPF is for the desktop, it's getting tedious and expensive to deploy the application in every computer, so I am urged to use "Silverlight Business Application" in order to access the applications via Web and, in the near future, to easily adapt to Windows Phone 7.

It seemed to be easy to move from WPF to Silverlight but I got run into some problems and the main has been at the level of data management: Silverlight does not support Datasets.

I felt a little frustrated because I feel forced to make a copy of all my functions / web services and modify them to return objects that are different from datasets.

However, so far I cannot find an object equal to or better than a dataset which, incidentally, can also let me use it interchangeably in both Silverlight and WPF.

Did anybody find a powerful and convenient solution that surpass the offered by a dataset? If yes, please let me know with examples or links in order to learn.

Thanks!!

+2  A: 

If your end users are all using Windows and are on the same network then you will be much better off sticking with WPF and using ClickOnce. I happen to love both WPF and Silverlight but Silverlight is a big freakin wuss when it comes to things people take for granted like file associations, multiple windows, integrating with other applications, etc.

But to answer your question, you will likely need to re-architect your data access strategy and use something like LINQ and WCF Data Services. The tooling support in Visual Studio will let you generate classes that are modeled after your database schema and your Silverlight/WPF UI can bind to these classes directly.

There is this project on CodePlex that seems to have a minimal implementation of DataSet/DataTable but honestly I wouldn't suggest sticking with DataSet. The reason Silverlight doesn't support DataSet is because the people have spoken and developers have rejected the wizard-driven DataSet model in favor of a much cleaner and more flexible ORM (Object-Relational Mapping) technology such as nHibernate or LINQ.

Josh Einstein
Silverlight can work with POCOs or any ORM really, no need for LinqToSql or WCF Data Services.
Michael Maddox
I wasn't trying to imply those were the only options. I said "something like" those and I did mention nHibernate at the end.
Josh Einstein
A: 

I have not had a whole lot of experience with Silverlight, but for WPF I have been very successful using Entity Framework (version 4, the EF that shipped with .NET 3.5 is kind of so-so).

Once you have defined classes and mapped them to your database tables, you can do all kinds of things that would take forever with datasets.

For instance: data validation. In Entity Framework, entity classes are partial classes, and thus you can customize them to a great degree. I put my validation code in there using a couple of dictionaries that track invalid property values. A little iDataErrorInfo here and there, and voila, I have easily bindable data validation that can trigger style changes in the UI.

I have not yet tried NHibernate or any other ORM tools. One day I will, but for now I have found EF to be enough for my purposes. Easy to figure out, easy to implement, a lot of customization, can be used with LINQ (LINQ to Entities), and it works pretty darned well with WPF.

Cory

OffApps Cory
Cory, I would really like to learn more about EF 4, I recently read web sites about this matter (including MS), but it seems that all the people that write about this, assume that all the world knows much about EF 4. How important is to know the philosophy behind this including "use cases".
http://www.windowsclient.net has been a big one for me. There are a number of videos(which I happen to like more than text due to the lack of typos that can completely screw up a recipe). After I started implmenting EF in some test projects, I also started migrating them to MVVM design. Also, a good book to read is the O'Reily Programming Entity Framework reference.
OffApps Cory