Description of the issue:
I want to validate the relation between classes in deserialized JSON object on the server. as an example: Claimed foreign key is correct between class A and class B.
A:
{
"Id": "z",
"B": [
{
"Id": "x",
},
{
"Id": "y",
}
]
}
In this case i want to figure out whether class A with Id "Z", has a valid relation to Class B with id "x" and "y" , And this can be deeper and deeper ... so B can have several inner relation and must be checked after B has been completely deserialized
I Don't want to write a recursive function, because i think it has lot of performance penalty for a server side program.
Some of property checks can be easily done using Newtonsoft.Json.Serialization.IValueProvider
but the problem is, i can't find out when a class has been completely deserialized ( all required properties has their own value in last public void SetValue (object target, object value)
call , some of them may have nothing at all and this feature is different for each class)
This part of server has been fully written with reflection and its completely generic.
So the question is:
How can i find out this SetValue
is the last SetValue call for this object? (for example object key is always the last call or something like it)
Or any other way for me to check this relation before IdentityDbContext.Update
Thanks