0

I have a WPF application which tightly coupled to linq2sql through WCF. It now turns out the Customer would like some sort of Offline mode using an xml file structure.

Lets say I have a Customers Table, Each Customer would have many Orders, with each order only belonging to one customer, so In my table design I would have a fk_CustId Column in my Orders table.

I would like to know if there is any straightforward pattern of serializing an instance of Customer(Linq2sql entity), so that it would automatically include the Order Child nodes in the xml.

Any help would be appreciated.

1 Answer 1

1

I'm not sure what you mean by "tightly coupled". If you are using Linq2Sql to fill your data contracts in the service, then when they get to the client they are no longer "live" Linq2Sql objects, but plain simple data transfer objects.

In other words, you have total control over what you choose to send from the service to the client in your data contract classes. Just modify your data contract classes to send what you want to send.

Sign up to request clarification or add additional context in comments.

2 Comments

What I mean is that since they are generated classes I have no control over how they are structured. For example, I wouldn't have a problem if Customer contained a List<Order> as this would serialize in a manner which would be satisfactory.
The best practice with writing services is to decouple your data contract classes from your data access layer classes, and manually copy the data across. I know that it seems like unnecessary work, but you won't regret it when your data contract classes or data access layer classes change.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.