Solved

Recommended Approach to Data Access with WPF

Posted on 2009-07-07
5
1,810 Views
Last Modified: 2013-11-11
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.
0
Comment
Question by:DevelopersAnonymous
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 24801059
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.
0
 

Author Comment

by:DevelopersAnonymous
ID: 24801414
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.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 24803774
>>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.
0
 

Author Comment

by:DevelopersAnonymous
ID: 24811694
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
0
 

Accepted Solution

by:
DevelopersAnonymous earned 0 total points
ID: 24836561
There appears to be no Microsoft 'best practice' as far as this goes. We have settled on Entity Framework with the aforementioned extensions.
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Software development teams often use in-memory caches to improve performance. They want to speed up access to, or reduce load on, a backing store (database, file system, etc.) by keeping some or all of the data in memory.   You should implement a…
Introduction This article discusses the Chain of Responsibility pattern, explaining What it is;Why it is; andHow it is At the end of this article, I hope you will be able to describe the use and benefits of Chain of Responsibility.  Backgrou…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question