ModelBinding to and EntitySet (MVC2 & LinqToSQL)
- by Myster
Hi all
There seems to be an issue with the default model binder when binding to an EntitySet causes the EntitySet to be empty.
The problem is described here and here:
Microsoft's response is:
... We have now fixed this and the fix will be included in .NET Framework 4.0. With the new behavior, if the EntitySet passed into Assign is the same object as the one its being assigned to, no action will occur.
With a work around being to edit the code generated like so:
public override EntitySet<Thing> Things
{
get
{
return this._Things;
}
set
{
//CORRECTION:
_Things= new EntitySet<Thing>();
_Things.Assign(value);
//WAS: this._Things.Assign(value);
}
}
As you can imagine this is not ideal as you have to re-add the code every time, does anyone have a better solution?