To property, or not to property?

I am trying to figure out what will give me the most pleasant code. I understand that this is a bit subjective.

I have an application that accesses a database for which I wrote an assembly that hides details about this database from all applications that use this assembly.

I also have a WPF application that uses this assembly to display various cost estimates in which I would like to use data binding.

Data binding is only possible for object properties (as far as I should work). This would mean that I need an object, preferably with INotify support and a number of objects. However, I would rather keep the INotify and WPF elements outside the assembly that handle database access.

How do others solve this: keep WPF stuff outside the database level (like INotify) and allow binding inside your WPF? Write a wrapper? Or do most people put the property / INotify class as a data transfer object directly at the database level?

+5
source share
6 answers

You are laboring in error. INotifyPropertyChanged not a WPF thing. Consider:

  • This is part System.dll
  • It is in the namespace System.ComponentModel
  • It has been part of the .NET Framework since version 2.0
  • It is supported by most of the .NET Framework data objects out of the box, including ADO.NET DataRowViewand ComponentModel ObservableCollection.
  • WinForms, ASP.NET, WPF .

Microsoft INotifyPropertyChanged, ? , - , . NET Framework?

- , , , , . INotifyPropertyChanged , , ?

: . , . , . , , , .

+3

,

+7

, - WPF INotify . INotify , .

+1

. , DTO

0

PostSharp, , Aspect Oriented Programming (AOP). , INotify * . PostSharp , , .

0

Another note that is useful - if you know that the property you are binding to is immutable (i.e. a singleton object or something that will be initialized once and never touched), you do not need to do this INotifyPropertyChanged - a simple property will work fine.

0
source

All Articles