ef4 cause Circular reference in web service

前端 未结 3 1155
庸人自扰
庸人自扰 2020-11-29 10:54

I have a Reason object:

public class Reason
{
    public virtual long Id { get; set; }
    public virtual string Name { get; set; }
    public virtual Comp         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-29 11:28

    I usually write specific classes for the webservice. While this is some extra work it has the advantage that the webservice gets more robust as small changes in your entities won't go unoticed and silently fail on the side of the consumer/javascript. For example if I change the name of a property.

    There are a few things you can do to reduce the work and one is to use AutoMapper which can automatically map between objects.

提交回复
热议问题