I have a service in ServiceStack with a DTO that returns multiple properties, but some can only be returned if the person is authenticated, or if some rule.
How can I do this?
The attribute can only be used in class or method and not a property.
I have a service in ServiceStack with a DTO that returns multiple properties, but some can only be returned if the person is authenticated, or if some rule.
How can I do this?
The attribute can only be used in class or method and not a property.
There are many ways to ignore properties in serialization, using Conditional Serialization is likely the most useful here.
But I'd personally avoid using bespoke serialization features and just use vanilla C# to set the properties you don't want to return to null
, either within your service or in one of the Custom Response Filters and Hooks.