Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Json Refernce Loop Ignore

...

Warning

1 VS N의 Entity를 Json으로 표현하려했을시 다음에러가 발생

JSON.NET Error Self referencing loop detected for type


Entity Sample : 1 VS N

[Table("user")]
public class User
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int UserId { get; set; }

public Profile Profile { get; set; }

public List<SocialInfo> SocialInfos { get; set; }

}

[Table("socaialinfo")]

public class SocialInfo
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int SocialId { get; set; }

[ForeignKey("UserForeignKey")]
public User User { get; set; }

public String SocialProviderName { get; set; }

public String SocialUserNo { get; set; }

public String NickName { get; set; }

}


위와같은 Entity가 있으며 , 사용자의 정보를 포함하여, 가입된 소셜을 모두 Json 보고자 한다고 가정해봅시다.

...