Giter VIP home page Giter VIP logo

Comments (7)

b9chris avatar b9chris commented on August 20, 2024

I committed and pushed a fix for the bug that gets the test I was struggling with to work, and the several I was checking on, but causes the 4 OwnedCollection tests to fail.

The core of my change is I check the DbContext for DbSets to determine which type to actually use to safely get an ObjectSet on the ObjectContext in GetKeysFor(). But again I suspect there's a smarter way to answer the which-class question... .

from graphdiff.

b9chris avatar b9chris commented on August 20, 2024

This is now fixed in my fork:

https://github.com/b9chris/GraphDiff

All tests passing including the test I introduced, and the 4 I mentioned.

I'd like to merge it into main when you get a chance.

from graphdiff.

refactorthis avatar refactorthis commented on August 20, 2024

hey b9chris,

I've had a look at the code and it looks great, and caching of metadata as well 👍
I did have a look around to see if there was a simpler way to find the EntityObject for a derived poco.. but no luck. I'll have a look again tomorrow but it seems reflection of the types as you've done is the best way.

Let me know if there is anything you would like to add, otherwise I'll update everything tomorrow.

from graphdiff.

b9chris avatar b9chris commented on August 20, 2024

Excellent! Thanks for the merge. I don't have any further modifications to make since it's both passing all tests and currently used in production code on our end.

from graphdiff.

refactorthis avatar refactorthis commented on August 20, 2024

After a lot of reading and playing with the Entity Framework I think I may have found a simpler way to get the information we need.

var metadata = ((IObjectContextAdapter)db).ObjectContext.MetadataWorkspace;
var type = metadata.GetItems<EntityType>(DataSpace.OSpace).Where(p => p.FullName == entityType.FullName).Single();

foreach (string name in type.KeyMembers.Select(k => k.Name))
    yield return entityType.GetProperty(name);

It seems the ObjectContext is smart enough to 'know about' entities which are derivatives of a base type registered with it, and keeps the EntityType for it in its metadata. I've tested the above with your tests and some extras I have created and they pass.

If you can think of a test that could break the above please let me know. I'll push to master soon.

from graphdiff.

refactorthis avatar refactorthis commented on August 20, 2024

07cacb0

from graphdiff.

b9chris avatar b9chris commented on August 20, 2024

Excellent! Yeah as long as it passes all tests it should do just as well. Thanks for looking into that, I knew what I threw together was a real hack, but hey first pass to get it working.

from graphdiff.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.