Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Commented Issue: Delta is not populating GUIDs or INT fields [648]

$
0
0
I'm looking to do partial updates on a web api controller action by using the Delta wrapper.

I have a model like such:

public class Person
{
public Guid PersonId { get; set; }

public string FirstName { get; set; }

public string LastName { get; set; }

public bool IsActive { get; set; }

public int NumVacationDays { get; set; }

public double Salary { get; set; }
}


I have the api controller like such:

public void Put(Delta<Person> person)
{
var p = person.GetEntity();

Person existingPerson = _repository.Get(p.PersonId);

person.Patch(existingPerson);

_repository.Update();

return;
}

I make the call to the web api like such (using fiddler)

url: http://localhost:49933/api/Person (PUT)


Response Body
{
"PersonId": "b269c49f-8a90-41d6-b102-7cfba3812b1c",
"FirstName": "sample string 2",
"LastName": "sample string 3",
"IsActive": true,
"NumVacationDays": 5,
"Salary": 6.1
}

The controller is hit and all the data is populated other than the NumVacationDays (which is 0) and the PersonId (which defaults to 00000000-0000-0000-0000-000000000000)

Does anyone know why the GUIDs and int fields are not populating from the json?
Comments: Hi, I tried this out locally and found that the NumVacationDays is getting populated as expected. As for the PersonId the behavior is expected. We don't want to enable PATCHING key properties by default. Keys generally map to the corresponding keys in the database and databases generally don't let you modify the key's (causes lots of issues). If you want to enable PATCHING keys, you can change the PatchKeyMode on the formatter to PATCH to support this. The code that I tried is at https://gist.github.com/4165306.

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>