I have a class with a public List property. This class is stored in a azure SQL DB using the entity framework - as such it cannot store the variable. To get around this issue i've created the backing field 'iUpdatedIdentifiers' which is a list seperated by '###', the code is as follows:
[JsonProperty("UpdatedIdentifiers")]
[System.ComponentModel.DataAnnotations.Schema.NotMapped]
public List<string> UpdatedIdentifiers {
get{
try{
return iUpdatedIdentifiers.Split(@"###").ToList();
}catch{
return new List<string>();
}
}
set{
string s = "";
foreach (string x in value)
{
s = s + x + "###";
}
iUpdatedIdentifiers = s;
}
}
[JsonIgnore]
public string iUpdatedIdentifiers {get;set;}
The code above works fine when retrieveing objects from the database using the entity framework and serializing the object to JSON. However when i attempt to deserialize the below JSON into the class the list is always empty.
{
"UpdatedIdentifiers":[
"edu308",
"edu310",
"edu312",
""
]
}
Any ideas on how to get around this issue?