WinSpace describe problem when moving business entities across layers in a project with LINQ for SQL and WCF in his article LINQ to SQL Serialization
" My project includes several layers, some layers require the business objects to be serialized before sending to another layer. Right now I am using strong-typed dataset to present more than two hundred tables in the database, but I still had to manually create near 100 serializable business objects in order to represent the entities.
LINQ to SQL was given me the hope to minimize the effort to create these business object classes. Those entity classes created by LINQ to SQL designer look like a very good candidate for the business objects that my project needs. But very quickly I realized that I was wrong.
- LINQ to SQL classes do not support the binary serialization. Although I can manually modify them to meet my need, it is very time-consuming job, and difficult to maintain if table is changed in future.
- LINQ to SQL classes can not be serialized by XML serialize if there is a relationship between tables. "
And he suggest to use his LinqSqlSerialization class library a solution to archives
- A serializable business object class for each entity, and I do not need the association between entities
- These business entity classes can be used in both XML serialization and Binary Serialization
- The work for generating these classes should be minimized and reusable for the other similar projects
Many one are asking about how to use LINQ generated object efficiently without manually creating business entities and passing data by from LINQ manually, and me too :D. Anyone here have the best practice to work with LINQ and WCF together ?