79319485

Date: 2024-12-31 08:18:59
Score: 2
Natty:
Report link

you are right i have a circular reference but it's normal because my CDM is like that : enter image description here

i will have 2 methods GetPublishers and GetBooks. When i will have the result for GetPublishers, i wanted to have this

    [
  {
    "PublisherId": 1,
    "PublisherName": "NamePublisher1",
    "BookPublisher": [
      {
        "BookPublisherId": 1,
        "BookId": 1,
        "PublisherId": 1,
        "Book": {
          "BookId": 1,
          "BookName": "TEST1",
        }
      },
      {
        "BookPublisherId": 2,
        "BookId": 2,
        "PublisherId": 1,
        "Book": {
          "BookId": 2,
          "BookName": "TEST2",
        }
      },
    ]
  }
]

and when i want the result of GetBooks, the result have to be this

[
  {
    "BookId": 1,
    "BookName": "TEST1",
    "BookPublisher": [
      {
        "BookPublisherId": 1,
        "BookId": 1,
        "PublisherId": 1,
        "Publisher": {
          "PublisherId": 1,
          "PublisherName": "NamePublisher1",
        }
      }
    ]
  },
  {
    "BookId": 2,
    "BookName": "TEST2",
    "BookPublisher": [
      {
        "BookPublisherId": 2,
        "BookId": 2,
        "PublisherId": 1,
        "Publisher": {
          "PublisherId": 1,
          "PublisherName": "NamePublisher1",
        }
      }
    ]
  }
]

So my class define before are ok and on the methode "OnModelCreating" i don't put relation.

Reasons:
  • Blacklisted phrase (1): enter image description here
  • RegEx Blacklisted phrase (1): i want
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Newbie_thefirst