I have a class like this:
public class Foo
{
public int Bar { get; set;}
}
This class is used to be stored in a NoSQL database so I need to store the Bar
value. However, I don't want to expose this value through my API.
So I created a class that inherits from Foo
that I will return from my API.
I created the method ShouldSerializeBar
by following the documentation I found here.
public class Foo2 : Foo
{
public bool ShouldSerializeBar()
{
return false;
}
}
However, the method is not called. Is there a workaround for this or another way to achieve this?