Questions about O/R mapper code generation
I've several questiions about the O/R mapper generated code from Visual Studio 2008 Beta 2:
- I've tried creating a One to One relationship between two of my tables. The foreign table has a nullable reference on the other one.
This generates non-compilable code because the O/R mapper tries to create a read/write property on the referenced table and thus tries to set the Id of my table to an Integer? value (which obviously fails since the Id is an Integer).
Will there be a way to mark a relationship as "one way", or better to hint to the generator that it should generate a read only property?
- The generator generates classes implementing INotifyPropertyChanging and INotifyPropertyChanged interfaces, but the implementation for the INotifyPropertyChanging method does not fill-in the property name. Is this an intended behavior or a bug?
- Is there a plan to generate more partial methods for catching adding and removall of objects in associated tables? If the INotifyPropertyChanging was working there would be a way to know something has changed on those, but still it would be nice to be notified of what has been added/removed, allowing to implement event signaling to the oustide world and to update others and the UI based on that. I love the auto-generated partial methods for property changes, and I think it would be a boon to have those on associated tables. Somehting like (in VB form):
partial private OnMyBusinessObjectAdded(instance as BusinessObject instance)
partial private OnMyBusinessObjectRemoved(instance as BusinessObject instance)
That would go a long way getting rid of boilerplate code for plumbing an application.
It seems to me that generating the same kind of code in attach_MyBusinessObject as in the object's own mapped properties would not be far fetched (I understand this might work only when adding the child object using the parent's exposed collection but that does not seem like a huge drawback for the added simplicity).
Thanks in advance.
Edit:
It's even worse than I thought because the generator bypasses the OnRefXXXChanging/OnRefXXXChanged completely when using the Entity methods. It accesses the storage field directly and does not call those methods.
The end result is that short of using the RefXXX instead of the XXX methods (which is contrary to what this entity model is designed for I think), there is no way to get proper signaling BEFORE the change has happened. The PropertyChanged method will be called with the XXX property name, but that's not enough. Since the PropertyChanging method implementation is broken, there is no way out of here.
I know it's always possible to write everything manually, but I hate writing boilerplate code.

