Comments (7)
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.
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.
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.
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.
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.
from graphdiff.
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)
- Update grandchild, where child is linktable
- Merge entity graph from database perspective
- GraphDiff support for EntityFramework Core? HOT 16
- What about transferring the project to somebody who have the inclination to maintain it? HOT 10
- when calling GetPrimaryKeyFieldsFor function
- How to Ignoring one or more fields HOT 7
- Update error when a table has two foreign keys pointing to the same table HOT 24
- Navigation Properties updated in incoming entity during UpdateGraph HOT 3
- I can't build it due to "zzzproject.pfx" HOT 4
- All tests fail, in the test project. HOT 1
- Problem in inheritance with aggregation HOT 2
- Description URL broken HOT 1
- Partially update owned collection HOT 9
- Autoincrement Id is not read back [not an issue or question] HOT 2
- Deleting join row only in a many to many scenario HOT 3
- Is this project still supported? HOT 11
- We need GraphDiff for EFCore HOT 7
- Description link is broken / documention not available HOT 4
- Data corruption when fixing up navigation properties HOT 10
- Associated Collection reference being update with parent
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphdiff.