© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
4 replies
Trou

C# .Net Core WebAPI Cyclic Dependancy

Hello, trying to make simple web api, have two classes Character and Episode both classes has nav property to other, wit ManyToMany relationship.
The problem is when i trying to Get data json data looks like this;

[
  {
    "name": "Pika",
    "status": "asdasd",
    "species": "adasd",
    "gender": "Male",
    "image": "adsas",
    "episodes": [
      {
        "name": "EP1",
        "airDate": "22323",
        "episodeCode": "asdadEP",
        "characters": [
          null
        ],
        "id": 1,
        "createdAt": "2024-03-03T18:40:23"
      }
    ],
    "id": 3,
    "createdAt": "2024-03-03T17:49:17"
  }
]
[
  {
    "name": "Pika",
    "status": "asdasd",
    "species": "adasd",
    "gender": "Male",
    "image": "adsas",
    "episodes": [
      {
        "name": "EP1",
        "airDate": "22323",
        "episodeCode": "asdadEP",
        "characters": [
          null
        ],
        "id": 1,
        "createdAt": "2024-03-03T18:40:23"
      }
    ],
    "id": 3,
    "createdAt": "2024-03-03T17:49:17"
  }
]

Here is my entites


public class Character : BaseEntity<long>
{
    ...SomeProps

    public ICollection<Episode> Episodes { get; set; }

}
public class Character : BaseEntity<long>
{
    ...SomeProps

    public ICollection<Episode> Episodes { get; set; }

}


public class Episode : BaseEntity<long>
{
    ...SomeProps
    
    public virtual ICollection<Character> Characters { get; set; } 
}
public class Episode : BaseEntity<long>
{
    ...SomeProps
    
    public virtual ICollection<Character> Characters { get; set; } 
}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ ASP.NET Core WebAPI - Cannot choose the AuthenticationScheme for MicrosoftGraphs?
C#CC# / help
3y ago
C# Cyclic Numbers Array Check Help
C#CC# / help
3y ago
✅ c# .net core wep api project issue.
C#CC# / help
2y ago
❔ About learning C# and Asp.net core
C#CC# / help
3y ago