WCF Contracts from Entity Framework?

后端 未结 4 2022
予麋鹿
予麋鹿 2021-02-14 06:52

I\'ve been coming up with a lot of dead ends on this question. Supposedly, .NET 3.5 SP1 has Support for ADO.NET Entity Framework entities in WCF contracts. But when I look for

4条回答
  •  孤独总比滥情好
    2021-02-14 07:37

    I recommend that you not return Entities directly. Unfortunately, Microsoft chose to include implementation-specific data as part of the DataContract for entities. This will not interoperate with other platforms, and is the sort of thing that might fail to interoperate even between .NET versions.

    Instead, I recommend you follow the Data Transfer Object pattern and just return POCO classes that are copies of the data in the entities, with no behavior. You can return List of such classes to represent a table, etc.

提交回复
热议问题