Nhibernate: Access.Property vs Access.CamelCaseField (WPF)

Posts   
 
    
zweps79
User
Posts: 16
Joined: 28-Feb-2011
# Posted on: 07-Jun-2011 13:29:06   

Hello,

We are developing a WPF application, where LLBLGen is a important tool for decreasing the workload.

In our application it is necessary that when data get changed under the hood, the binded UI components (WPF) get notified and change along. We already have built in INotifyPropertyChanged (by using aspects and PostSharp) for all our properties in the Model layer.

In the datamapping (we use FluentNHibernate because of its many benefits), we have **replaced the default Access.CamelCaseField with Access.Property settings **(the only exception is the ID field, which only has a getter, so there CamelCaseField stays the case), so that when data changes on databaselevel, the corresponding Property in the Model is set via the mapping (and thus notified because of the INotifyPropertyChanged interface) instead of the private field member.

In LLBLGen however, this is not possible other then doing this in the template.

Is there a **reason why **this is not supported by settings in LLBLGen?

Anyone **some ideas/comments **why not to use Access.Property (Property) instead of Access.CamelCaseField (private member)?

Regards,

Marthijn

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 07-Jun-2011 15:36:13   

Did you implement INotifyPropertyChanged using the proxy factory of NHibernate? We use the backing field as this is the recommended approach in NHibernate

Frans Bouma | Lead developer LLBLGen Pro
zweps79
User
Posts: 16
Joined: 28-Feb-2011
# Posted on: 08-Jun-2011 09:32:33   

We did implement the INotifyPropertyChanged interface by defining aspects in the LLBLGen entityClass template, which are interpreted by PostSharp (tool) so the interface is coded in the DLL when building the project.

We don't see any problems using Access.Property for accessing the data fields via properties in our dataobjects, since we won't mix any code in the getters or setters of the properties, so it stays leightweight.

Do you see any downsides?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 08-Jun-2011 09:44:35   

There's no real issue with Access.Property, true. We didn't implement a setting for it because we didn't think about when one would want to change it, as the properties and backing fields are generated always anyway, so it would be a setting which had no effect.

Except of course in your situation, something we didn't think of.

Have you looked at this way of implementing INotifypropertychanged: http://ayende.com/blog/4106/nhibernate-inotifypropertychanged ?

Also, can't the aspects be targeting the backing field instead?

Frans Bouma | Lead developer LLBLGen Pro