I am trying to do some process against every object in my EntityFramework OnSave. Part of this process involves turning the object into a Binary object. It is taking FOREVER to Serialize and I am about 99% positive that it is because we are using Lazy Loading on our EntityFramework and it is grabbing Lazy Loaded objects that are accessed in PartialClasses.
I tried detaching my object from the ObjectContext, but my coworkers have used Lazy Loading all over our application without first checking if the object was NULL.
For example, there is code like this in our Partial Classes file:
get { return this.ContactsTable.FullName; }
That works fine as long as the object is not Detached. As soon as it is detached I get Null reference errors.
My question is this: Is it possible for me to detach my object and have Lazy Loading not throw Null Reference exceptions, OR is it possible for me to tell the DataContractSerializer to ignore Lazy Loaded objects?