User defined Serialization for LINQ to SQL generated classes

B

Benjamin Kalytta

Hello there,

is there a way to override predefined Serializer for LINQ to SQL class objects?

MSLinqToSQLGenerator generates classes for accessing Database.

I want to create a Webservice which should be able to do certain Operation on
Database and should serialize certain objects. Serializer will try to serialize
all object Properties/fields. I need to prevent certain fields to be included in
serialization because of exceptions caused by cyclic depencies within.

Example:

There is a Table "Customers" in Database. LINQ To SQL Generator will generate
class "Customer" like


[Table(Name="dbo.Customers")]
public partial class Customer :
INotifyPropertyChanging,
INotifyPropertyChanged {

....
public int SomeFieldToExclude;
....

Say there is a field "SomeFieldToExclude" that should not be included in any
Serialization (especially for SOAP Webservices). How can I prevent Serialization
of this Field?

Also note, since this class is automatically generated you can (should) not
modify anything in this file however you can create a new file and extend the
same class since it is a partial class.

Is there any way?

Benjamin Kalytta
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top