Error when making post request with entity framework
772
My question is the following:
where I am going to update evaluating that the ot parameter matches one that is already inserted previously, but when sending it it shows me errors and I don't know how to solve it
You create an object AutorizacionCLS, but since you're just creating it, this is a null object.
When entering the validation of the if(oAutorizacionCLS.Ot.Contains(ot)), you are validating in the following way: If it oAutorizacionCLS.Otcontains otthen you proceed to process what is inside the if.
But what about this validation? Turns out your object oAutorizacionCLS.Otis null, because you created it but never assigned values to it. So here is the error object reference not set to an instance of an object.
If you want to validate that otit's inside your object oAutorizacionCLS.Ot, make sure you query first for the data you need to update and thus fill your object with data that you can validate if otit's inside your object with values.
You get the error because of the following:
AutorizacionCLS
, but since you're just creating it, this is a null object.if(oAutorizacionCLS.Ot.Contains(ot))
, you are validating in the following way: If itoAutorizacionCLS.Ot
containsot
then you proceed to process what is inside theif
.oAutorizacionCLS.Ot
is null, because you created it but never assigned values to it. So here is the errorobject reference not set to an instance of an object
.If you want to validate that
ot
it's inside your objectoAutorizacionCLS.Ot
, make sure you query first for the data you need to update and thus fill your object with data that you can validate ifot
it's inside your object with values.