Conditional DataContract Serialization in WebApi
问题 I am trying to find the best way to conditionally include and remove properties from my datacontract serialization in my .net WebApi project. In my Api, I want to allow users to specify the fields that they want returned. For example, assume I want my API to return an instance of the following class. public class Car { public int Id { get; set; } public string Year { get; set; } public string Make { get; set; } public string Model { get; set; } public string Color { get; set; } } But instead