views:

18

answers:

1

In our Smartclient app we currently use PostSharp to inject get/set code into auto properties to implement Dirty state tracking and INotifyPropertyChanged events.

We often use these business objects with LinqToSql. We'd like to remove this dependency on Postsharp, and the .Net 4.0 ExpandoObject looks perfect. We can add dynamic properties and add custom get/set code without having to repeat it on every property for the HasChanged() implementation.

My question is this; How do we get instances of dynamic ExpandoObject from LinqToSql? Is it at all possible?

If not, is there some other way this can be achieved? we basically have business objects with 50-100 properties on each, and need to implement INotifyPropertyChanged without hundreds of lines of repetitious code

A: 

It looks like for now there are three ways to go about this

  1. Proxy objects e.g. Castle Dynamic proxy
  2. Code generation e.g. T4 templates
  3. Code weaving e.g. Postsharp

Postsharp seems to be a good method for us, since we get the desired behaviour using the defaukt constructor, and don't have to worry about the maintenance of generated code. We just add an attribute to a POCO entity and just forget about it.

Andronicus