Solved

Recommended Approach to Data Access with WPF

Posted on 2009-07-07
5
1,763 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
  • 3
  • 2
5 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
Comment Utility
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
Comment Utility
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
Comment Utility
>>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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I'd like to talk about something that is near and dear to my heart: build systems. Without them, building software is all about compiling locally, with software versions everywhere. It can be a mess. Today we are going to discuss building a small di…
"Disruption" is the most feared word for C-level executives these days. They agonize over their industry being disturbed by another player - most likely by startups.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

771 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now