jods

The code generated by the linq designer currently looks like this:
Code Snippet

public Choice()
{
OnCreated();
this._EventResults = new EntitySet<Result>(new Action<Result>(this.attach_EventResults), new Action<Result>(this.detach_EventResults));
this._Event = default(EntityRef<Event>);
}



(EventResults and Event are a 1-n and n-1 associations.)
OnCreated is a partial method which allows me to insert custom initialization logic into the Choice class. That's great. But I think it should definitively happen after the linq generated initialization.

Here's are a few simple use cases.
  1. I'd like to insert a default Result each time a choice is created. I can't do it inside OnCreated because EventResults doesn't exist yet, or will get overwritten as soon as I return from OnCreated.
  2. I'd like to register an handler for EventResults list modifications (e.g. to work around the lack of proper databinding suport). Again, it's impossibile to do it at this point because EventResults is not instanciated yet.
I hope this can get changed before RTM...


Re: LINQ Project General [Linq to SQL beta 2] OnCreated is not very useful in the current execution sequence

Matt Warren - MSFT

I agree this is a problem. The call to OnCreated is being moved to after the other items are initialized. The change will appear in RTM.