Link to home
Start Free TrialLog in
Avatar of DevelopersAnonymous
DevelopersAnonymousFlag for Australia

asked on

Recommended Approach to Data Access with WPF

Is there a Microsoft recommended choice of Data Access Layer (DAL) for use with WPF? If not, what options are available and what are the features/advantages/disadvantages of each approach?

The options seem to be:
1. Using Entity Framework with WPF
 - This supports PropertyChanged and PropertyChanging events
 - This does not use a POCO model by default
 - To use a POCO model the following framework is provided http://www.pnpguidance.net/Post/EntityFrameworkPOCOPersistanceIgnoranceAdapterEFPocoAdapter.aspx

2. Using Linq objects
 - These do not support PropertyChanged and PropertyChanging events by default
 - Some templates are available in the community to support these events

3. Other DALs such as SubSonic, CSLA.NET, Sculpture .NET etc
 - These support PropertyChanged and PropertyChanging events

4. Reflection Emit of data access objects

Note: there may be a requirement to support Silverlight.
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

well, let's start with the more constrained requirement: silverlight. It doesn't support database directly. You have to use an intermediary WCF service to have database access.
About PropertyChanged events, it is not related with DAL at all, but with business layer and closely related with presentation layer.
Avatar of DevelopersAnonymous

ASKER

Hi jaime_olivares,

Thanks for your response.


Firstly, Silverlight still has to bind to a data object (and yes it must be retrieved from a WCF or web service). I define a data object as a code representation of the table or view or type generated from a stored procedure. The data objects are contained in DAL assemblies, this is called the data layer.

A business object in a system will use these data objects from the DAL (and preferrably the UI for the system will use these data objects as well). Thus the data objects must support the PropertyChanged, PropertyChainging or other events that you might want to add (say with aspect injection).

I also should have said that our preference is that our DAL supports stored procedures, apparently this is not done very well with entity framework. However there is a library on codeplex called EFExtensions that massively improves the handling of stored procs.

Idealy, I would like to emit the EF framework objects and then use them in memory without reflection so that I get super fast performance and type safety.
>>A business object in a system will use these data objects from the DAL (and preferrably the UI for the system will use these data objects as well)

Ideally PL shouldn't know about data objects, just about bussiness objects, because BO use to have some extra logic inside to validate or calculate some fields, or generate more than one data transaction per each bussiness transaction.
So, what you expose in webservice are bussiness objects, not data objects at all.

The update control should be done at BL and not at DL, because the reasons exposed (some fields to validate/calculate or extra transactions), although Entity Framework can help BL in ensuring relational data integrity.
What is definitive is that you cannot use Entity Framework objects into your silverlight application unless you expose them in a service contract, but this will move your BL to the silverlight app itself, which is basically just a presentation layer.
Hi jaime_olivares,

Thanks again for your response.


I agree with you that in times past it was important to maintain seperate Data Objects and Business Objects, but in the modern world of scaleable stateless architectures, this is no longer important. Our data objects reside in a shared layer which is accessible by the DAL, BLL and PL. I never suggested that updates would be propegated at the DAL, they will occur at the BLL.


We have narrowed our choice of DALs down to:
 - Entity Framework with EFPocoAdapter and EFExtensions
 - Linq objects
 - Sculpture .NET

Our main considerations with these are:
 - Support of POCO
 - Support of PropertyChanged and PropertyChanging events

We are seeking:
 - Knowledge as to whether Microsoft has a recommended approach to this problem when dealing with WPF.
 - A comparison of the features/advantages/disadvantages of these DALs
 - Any user experience/recommendations
ASKER CERTIFIED SOLUTION
Avatar of DevelopersAnonymous
DevelopersAnonymous
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial