.net-corepartial-response

Partial Response Field Projection .Net Core


I have an object

[DataContract]
class User {
  [DataMember(Name = "id")]
  string Id { get; set; }

  [DataMember(Name = "first_name")]
  string FirstName { get; set; }

  [DataMember(Name = "address")]
  string Address { get; set; }
}

[DataContract]
class Address {
  string Street { get; set; }
}

This object would get returned by a REST url /user/abc however if I want to return only specific properties, I want to use Google's syntax ?fields=id,first_name,address(street).

Is there already a module in .NET Core that serialises only the required fields or do I have to code this myself? If so, how would I go about doing that?


Solution

  • There is already a module for this https://github.com/dotarj/PartialResponse