Support change tracking of non-primitive types
See original GitHub issueChangeTracker does not detect changes to properties of type Dictionary<,>. In provider for PostgreSQL database database column type hstore is mapped to .net type Dictionary<string,string> but this feature can not be used properly if we do not have change tracking for those properties. One solution would be to use ImmutableDictionary but we want to avoid that.
Steps to reproduce
public class HStoreContext : DbContext
{
public DbSet<SomeEntity> SomeEntities { get; set; }
}
public class SomeEntity
{
public int Id { get; set; }
public Dictionary<string, string> Tags { get; set; }
}
using (HStoreContext ctx = CreateContext())
{
var entity = new SomeEntity()
{
Tags = new Dictionary<string, string>()
};
ctx.SomeEntities.Add(entity);
var num = ctx.SaveChanges();
Assert.Equal(1, num);
var entry = ctx.Entry(entity);
Assert.Equal(EntityState.Unchanged, entry.State);
entity.Tags.Add("kind", "new");
ctx.ChangeTracker.DetectChanges();
Assert.Equal(EntityState.Modified, entry.State); // This fails
}
Further technical details
EF Core version: 2.0.0 Database Provider: Microsoft.EntityFrameworkCore.PostgreSQL Operating system: IDE: Visual Studio 2017
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (7 by maintainers)
Top Results From Across the Web
Data Types in Java | Primitive and Non-Primitive Data Types
This article on Data Types in Java will give you a brief insight into various primitive and non primitive data types in Java...
Read more >Java Non-Primitive Data Types
Primitive types are predefined (already defined) in Java. Non-primitive types are created by the programmer and is not defined by Java (except for...
Read more >Difference Between Primitive and Non Primitive Data Types
Mutable data types require more resources since each change must be tracked and stored in memory; this results in increased overhead but also ......
Read more >What are the non primittive data types in salesforce
The non primitive data types in salesforce are the sobjects such as Standard objects and custom objects. ... sObjects, collections, user-defined ...
Read more >protocol-buffers serialization with large list of non-primitive ...
Specifically my question is: could I change my protobuf-net usage, or possibly serialization library, to get a smaller message size? I'll give ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just to report that I’ve value comparison for hstore seems to work perfectly… I’ll be adding comparers to array and other relevant types for 2.1 as well.
Thanks!
@ajcvickers if you’re interesting in seeing a complex/interesting comparer implementation, take a look at the array comparer, it will also illustrate some of the issues detailed in #11072.