0

client send object like this

{ID:1,JSONArray:[{Name:"pooria",LastName:"Shariatzadeh"},{Name:"jon",LastName:"smith"}]}

and My EF db First Class looks like This :

    public partial class entity
{
    public int ID { get; set; }
    public string JSONArray { get; set; }
}

how can i implant something to Serializing and Deserializing automatically with Json.NET

i now how to Serializing and Deserializing json i just want something like interface,Attribute or such thing for doing this in proper way

my solution is stringify JSONArray in client for setData and parse it when i get data but i want to do it in server side

Pooria.Shariatzadeh
  • 291
  • 2
  • 4
  • 16

1 Answers1

0

i have come with this solution

   public partial class entity
   {
      public int ID { get; set; }
      public string JSONArray { get; set; }
      public List<JSONArray> JSONArrayList
    {
        get { 
        if (Tags != null)  
           return JsonConvert.DeserializeObject<List<JSONArray>>(JSONArray); 
        else 
            return null; 
    }
        set 
         { 
           if (value != null) 
           JSONArray = JsonConvert.SerializeObject(value);
         }
    } 
  }


  public class JSONArray
    {
        public string Name { get; set; }
        public string LastName { get; set; }
    }

If you have it in another Way please share

Pooria.Shariatzadeh
  • 291
  • 2
  • 4
  • 16