How to return LINQ to SQL Table object from WCF service?

The following method in my WCF implementation:

public Campaign GetCampaignByDisplayName( String displayName )

where Campaignis the table in my SQL Server database, my client application throws an exception when the above method returns. From other related posts, I read that the problem is probably related to what is Campaignnot serializable. Going to the source file of the developer of the generated database and properly ignoring the warning "Changes in this file may lead to incorrect behavior ..." I add an attribute [Serializable]to the class Campaign, resulting in a once compiled proxy file that is regenerated.

It is clear that there is no critical concept. What do I need to do to pass the LINQ to SQL record this way?

+3
source share
2 answers

Check the class of the campaign DataContractAtribute.
Check all participants that you want to transfer through the web service with DataMemberAttribute.

MSDN has a decent primer - http://msdn.microsoft.com/en-us/library/ms733127.aspx

+3
source

If you are using sqlmetal use / serialization: Unipirectional

http://msdn.microsoft.com/en-us/library/bb386987.aspx

0
source

Source: https://habr.com/ru/post/1778651/


All Articles