A lot of WCF its internal components can be extended or replaced by custom, user developed implementations.
Not surprisingly, we can also hook into the WSDL meta data generation.
Of course creating the endpoints dynamically in code at runtime could also have solved this problem, but that would result in code that is not reusable and the WCF service programmer would have been responsible for the implementation.
By developing this as a behavior, it is reusable across services.
Even if you are serializing proxy objects in place of the LINQ to SQL entities, you still have to construct an entity on the data access layer (DAL), and attach it to a new System. LINQ to SQL is completely indifferent about how entities are serialized.
For more information about how to use the Object Relational Designer and SQLMetal tools to generate classes that are serializable by using Windows Communication Foundation (WCF), see How to: Make Entities Serializable. The only way for an entity to be detached from its original data context is for it to be serialized.
In my previous article, we saw how to delete a Custom List using the REST API.
This works fine and gives no issues when calling the service from another computer, but it has one important drawback: WCF will use the localhost address in the generated WSDL meta data.
In order to fix this, I created a custom WCF behavior.
However, if your application requires that clients be able to update or delete data, then you must attach the entities to a new data context before you call Data Context. In addition, if you are using an optimistic concurrency check with original values, then you will also need a way to provide the database both the original entity and the entity as modified.
The methods are provided to enable you to put entities into a new data context after they have been detached. Data Context, in order to submit the data to the database.
When you serialize entity objects such as Customers or Orders to a client over a network, those entities are detached from their data context.