question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support change tracking of non-primitive types

See original GitHub issue

ChangeTracker 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:closed
  • Created 6 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
rojicommented, Feb 27, 2018

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!

0reactions
rojicommented, Feb 27, 2018

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found