I am using WCF data services (5.6 now) and since Enums are not supported (and for other reasons), I have some additional properties added to the client side classes that I intend to remove during SaveChanges using the WritingEntity event following the example in http://blogs.msdn.com/b/phaniraj/archive/2008/12/11/customizing-serialization-of-entities-in-the-ado-net-data-services-client-library.aspx
My constructor attaches the event but I find that sometimes the event fires and other times (more often) it doesn't.
public MyDataContext(System.Uri serviceRoot, bool ignoreProperties)
: this(serviceRoot)
{
if (ignoreProperties)
this.WritingEntity += EdiContext_WritingEntity;
this.SendingRequest2+=OnSendingRequest;
}
To Save changes
db.AttachTo("Maps", map, "*");
db.UpdateObject(map);
ProcessMapCoordinates(db, map);
ProcessModifiers(map, db);
db.SaveChanges();
The SendingRequest2 event does fire, I use it to attach some header information to the request in order to support multiple data
private void OnSendingRequest(object sender, SendingRequest2EventArgs e)
{
e.RequestMessage.SetHeader("profile", ClientSettings.Instance.Profile);
}
Does anyone know under what circumstances the WritingEntity event will not fire?
Is there another way to prevent extended properties from the partial class from being serialized?
Thanks