json-patch

JsonPatchDocument onto a complex Entity Framework tracked object

北战南征 提交于 2020-12-31 04:59:45
问题 I am trying to use Json patches to update entities stored in an Entity Framework data context. I have entity classes like so - public class Customer { public Guid Id { get; set; } public string Name { get; set; } public virtual ICollection<Quote> Quotes { get; set; } } public class Quote { public Guid Id { get; set; } public int Order { get; set; } public string Status { get; set; } } To apply the patch onto a Customer object, I query the source from the data context, then apply the patch,

JsonPatchDocument onto a complex Entity Framework tracked object

北城以北 提交于 2020-12-31 04:55:49
问题 I am trying to use Json patches to update entities stored in an Entity Framework data context. I have entity classes like so - public class Customer { public Guid Id { get; set; } public string Name { get; set; } public virtual ICollection<Quote> Quotes { get; set; } } public class Quote { public Guid Id { get; set; } public int Order { get; set; } public string Status { get; set; } } To apply the patch onto a Customer object, I query the source from the data context, then apply the patch,

JsonPatchDocument onto a complex Entity Framework tracked object

≯℡__Kan透↙ 提交于 2020-12-31 04:55:21
问题 I am trying to use Json patches to update entities stored in an Entity Framework data context. I have entity classes like so - public class Customer { public Guid Id { get; set; } public string Name { get; set; } public virtual ICollection<Quote> Quotes { get; set; } } public class Quote { public Guid Id { get; set; } public int Order { get; set; } public string Status { get; set; } } To apply the patch onto a Customer object, I query the source from the data context, then apply the patch,

JsonPatchDocument onto a complex Entity Framework tracked object

梦想的初衷 提交于 2020-12-31 04:55:13
问题 I am trying to use Json patches to update entities stored in an Entity Framework data context. I have entity classes like so - public class Customer { public Guid Id { get; set; } public string Name { get; set; } public virtual ICollection<Quote> Quotes { get; set; } } public class Quote { public Guid Id { get; set; } public int Order { get; set; } public string Status { get; set; } } To apply the patch onto a Customer object, I query the source from the data context, then apply the patch,

GraphQL Mutation with JSON Patch

╄→гoц情女王★ 提交于 2020-08-05 07:18:21
问题 Are there any data types in GraphQL that can be used to describe a JSON Patch operation? The structure of a JSON Patch operation is as follows. { "op": "add|replace|remove", "path": "/hello", "value": ["world"] } Where value can be any valid JSON literal or object, such as. "value": { "name": "michael" } "value": "hello, world" "value": 42 "value": ["a", "b", "c"] op and path are always simple strings, value can be anything. 回答1: If you need to return JSON type then graphql have scalar JSON

JsonPatchDocument is null after migration to .Net Core 3

让人想犯罪 __ 提交于 2020-04-18 06:48:27
问题 I have a AspNetCore-WebApi-Project with several patch-operations, which worked fine with Core 2.2. After migration to Core 3 the [FromBody] JsonPatchDocument<T> is null. My Get/Post-Methods are still functioning as expected. This is one part of my Startup: services.AddDbContext<MyContext>(options => options .UseLazyLoadingProxies() .UseNpgsql(Configuration.GetConnectionString("MyConnectionString"), opt => opt.UseNodaTime())); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo {

How can I create a JsonPatchDocument from comparing two c# objects?

喜夏-厌秋 提交于 2019-12-31 08:47:19
问题 Given I have two c# objects of the same type, I want to compare them to create a JsonPatchDocument. I have a StyleDetail class defined like this: public class StyleDetail { public string Id { get; set; } public string Code { get; set; } public string Name { get; set; } public decimal OriginalPrice { get; set; } public decimal Price { get; set; } public string Notes { get; set; } public string ImageUrl { get; set; } public bool Wishlist { get; set; } public List<string> Attributes { get; set;

How is the tilde escaping in the JSON Patch RFC supposed to operate?

做~自己de王妃 提交于 2019-12-23 15:26:54
问题 Referencing http://tools.ietf.org/html/rfc6902#appendix-A.14: A.14. ~ Escape Ordering An example target JSON document: { "/": 9, "~1": 10 } A JSON Patch document: [ {"op": "test", "path": "/~01", "value": 10} ] The resulting JSON document: { "/": 9, "~1": 10 } I'm writing an implementation of this RFC, and I'm stuck on this. What is this trying to achieve, and how is it supposed to work? Assuming the answer to the first part is "Allowing json key names containing /s to be referenced," how

JsonPatch in an Angular/.NET Web API project

十年热恋 提交于 2019-12-10 11:31:11
问题 I'm utilizing KevinDockx's JsonPatch extension for Visual Studio. My project uses .NET Web API (not Core) and Angular (6) . .Net Web API doesn't support the JsonPatchDocument namespace, thus the need for KevinDock's JsonPatch extension. I'm reading through his documentation here: https://github.com/KevinDockx/JsonPatch/blob/master/README.md JsonPatch consists of two parts: On the client (consumer of the API) : the JsonPatchDocument / JsonPatchDocument class to build what's essentially a

How to Update Model in ASP NET MVC 6?

大城市里の小女人 提交于 2019-12-10 09:58:16
问题 Scenario: How to update a model? ASP MVC 6 I am trying to update a model. For passing the model information to the client(browser/app) I am using the DTO. Question 1: For updating, should I post the whole object back? Question 2: Is there a way I can easily pass only the information that is updated? If yes, how? Question 3: Can I use JSON Patch for updation? 回答1: Question 2: Is there a way I can easily pass only the information that is updated? If yes, how? Yes. You should create a view model