I am trying to figure out what would give me the nicest code. Which is a little subjective of course, I realize.
I have an application that accesses a database for which I have written an assembly that hides details about this database from all the applications that make use of this assembly.
I also have an WPF application that makes use of this assembly to display various cost calculations in which I would like to use databinding.
Databinding is only possible to properties of objects (as far as I got to work). This would mean I would need an object, preferably with INotify support and a range of objects. However, I would prefer to keep INotify and WPF things outside the assembly that handles database access.
How do others solve this: Keep WPF things outside the database layer (such as INotify) and inside your WPF allow binding? Write a wrapper? Or do most people put a 'property'/'INotify' class as data transfer object directly into the database layer?
In economics and political economy, there are three broad forms of property: private property, public property, and collective property (also called cooperative property).
Generally, “real property” is real estate. It includes the land and any permanent improvements to the land like buildings, fences, landscaping, driveways, sewers, or drains. “Personal property” is all property that is not real property like automobiles, livestock, money, and furniture.
Real estate is considered real property that includes land and anything permanently attached to it or built on it, whether natural or man-made. There are five main categories of real estate which include residential, commercial, industrial, raw land, and special use.
Owner-occupiers enjoy concessionary property tax rates ranging between 0 per cent and 16 per cent, while the property tax rates for those who rent out their flats range between 10 per cent and 20 .
Other people solve this by implementing the MVVM design pattern.
You are laboring under a misconception. INotifyPropertyChanged
is not a WPF thing. Consider:
System.dll
System.ComponentModel
namespaceDataRowView
and ComponentModel's ObservableCollection
.Since all the automatically-generated data layers Microsoft produces implement INotifyPropertyChanged
, why should you treat your data layer any differently? Obviously your data layer needs to notify its clients somehow when properties change. Why not use NET Framework's built-in mechanism?
In my opinion any data layer containing mutable objects should implement property change notifications as a matter of course. INotifyPropertyChanged
was designed to be such a notification mechanism, so why not use it as it was intended?
On a more general note: Adding an extra wrapper layer is generally just inefficient code bloat. Sometimes it is necessary and even beneficial, but don't do it just for the sake of doing it. Many times reasonably designed data layer objects work very well as view models. Only where your view model diverges from your data layer or where you need additional functionality should you consider introducing extra complexity, and then only on a case-by-case basis.
I think the cleanest solution is to write a wrapper object in your WPF assembly and keep the INotify
types out of the database assembly. There is no reason to add the complication of INotify
to the database layer unless it provides a specific advantage.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With