Nov
18
2009

Undocumented DomainService Wizard change in WCF RIA Services

UPDATE: Turns out this is a bug, check this newer post.

As everybody is busy upgrading their .NET RIA Services application to a WCF RIA Services application, there is one change that wasn't documented as it isn't a breaking change but it is something you probably want to look at. The DomainService wizard generated Update methods slightly differently then it used to.

The previous version would have generated something like this:

public void UpdateMyEntity(MyEntity currentMyEntity)
{
    this.ObjectContext.AttachAsModified(currentMyEntity, this.ChangeSet.GetOriginal(currentMyEntity));
}

The new version will look like this:

public void UpdateMyEntity(MyEntity currentMyEntity)
{
    if ((currentMyEntity.EntityState == EntityState.Detached))
    {
        this.ObjectContext.AttachAsModified(currentMyEntity, this.ChangeSet.GetOriginal(currentMyEntity));
    }
} 

If you don't want to regenerate all of your DomainServices I recommend going through and making this change yourself. It is a pretty easy change and makes sure that your code matches everybody elses.

UPDATE: The Breaking Changes document is being updated to have this information.

blog comments powered by Disqus

Month List