0
I’m creating a WebApi
where his return and the following.
[{
"$id": "1",
"Operadora": {
"$id": "2",
"Contato": [{
"$ref": "1"
}, {
"$id": "3",
"Operadora": {
"$ref": "2"
},
"id": 5,
"telefone": "99999-9999 ",
"cor": "yeloow ",
"data": "2017-01-23T00:00:00",
"id_operadora": 1,
"nome": "Fernando "
}],
"id": 1,
"nome": "Vivo ",
"codigo": 15,
"categoria": "Movel ",
"preco": "1 "
},
"id": 1,
"telefone": "99999-9999 ",
"cor": "blue ",
"data": "2017-01-23T00:00:00",
"id_operadora": 1,
"nome": "Jose "
}, {
"$ref": "3"
}, {
"$id": "4",
"Operadora": {
"$id": "5",
"Contato": [{
"$ref": "4"
}],
"id": 3,
"nome": "CLARO ",
"codigo": 21,
"categoria": "Movel ",
"preco": "1 "
},
"id": 6,
"telefone": "99999-9999 ",
"cor": "yeloow ",
"data": "2017-01-23T00:00:00",
"id_operadora": 3,
"nome": "Carlos "
}]
am using WebAPI
with Entity Framework from database
.
These are automatically generated classes .
{
using System;
using System.Collections.Generic;
public partial class Contato
{
public int id { get; set; }
public string telefone { get; set; }
public string cor { get; set; }
public Nullable<System.DateTime> data { get; set; }
public int id_operadora { get; set; }
public string nome { get; set; }
public virtual Operadora Operadora { get; set; }
}
}
using System;
using System.Collections.Generic;
public partial class Operadora
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public Operadora()
{
this.Contato = new HashSet<Contato>();
}
public int id { get; set; }
public string nome { get; set; }
public Nullable<int> codigo { get; set; }
public string categoria { get; set; }
public string preco { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<Contato> Contato { get; set; }
}
}
My problem and the next one, foreign key
for Operadora
, when in the contact’s registration I put the same id_operadora
the JSON
returns all who are with the same id_operadora
all in the same NO
.
anyone knows , how could solve this ? each registration in your NO ?