Comments (3)
Hi,
yes, there is an easier way. The mapping really is just a tree of GraphNodes representing what's normally specified using expressions. Of course you can replace the ConfigurationVisitor for your scenario and create GraphNodes directly, bypassing expressions and the ConfigurationVisitor entirely. Issue #9 proposes to do this using attributes on navigation properties.
As I'm not maintaining this repository I can't give you a definitive statement regarding the desirability of the proposed features. Personally I think the loading part could be a bit out-of-scope for GraphDiff while the async feature might be nice to have.
from graphdiff.
Finally circling back to this - had time to pick apart the ConfigurationVisitor.
Although the MVC-specific use case is definitely outside the scope of EFGraphDiff, the more I think about it the more the following seems in scope - at least to me - and I'm interested in thoughts:
- Loading Entities using the same *Configuration as one would use to Update them.
- Creating Blank Entities using the same *Configuration
- Deleting Entities using the same *Configuration
For now I'm focused solely on (1), but I'm interested in feedback as to whether others would agree loading an Entity using this config seems in-bounds for this library. Since it's C# it's not like the increased code is harmful to implementers, and MVC is just one case where it'd have a lot of use.
To get more detailed, after looking at the code I see the ConfigurationVisitor
loops over the entire Expression/method body to determine the kinds of collections that need to be saved. In other words, the way UpdateGraph()
works, it requires an Expression inside an Expression like:
x => x
.OwnedCollection(m => m.Urls)
.OwnedCollection(m => m.ContactInfos)
It does this because the work it's going to do needs a List like this:
List<Expression<Func<TModel, TItem>>>
with strong types for TItem
- differing types - all mixed into the same List, which would obviously be illegal in C#. So instead you have this Expression that's a sequence of statements, which the ConfigurationVisitor then loops over via Reflection and gathers these method call names and types, and determines handing that off to do the proper work of updating the appropriate collections and properties.
Assuming EFGraphDiff doesn't move to attributes as you mentioned, it would appear the best way to accomplish the Loading functionality I'd like would be to:
- Expose the ConfigurationVisitor to the outside. This means taking it out of Internal, which is the main reason I want to check here first before I proceed.
- Offer some extension point(s) in ConfigurationVisitor so the current functionality where it then creates the various OwnedEntityGraphNode, etc is just one potential use of it.
- Use those extension point(s) internally to ensure the current functionality remains the same.
- Use those extension point(s) in my code, which I could contribute back to EFGraphDiff or keep outside it, or.... something else? To accomplish this automated loading functionality.
I may just do this anyway and end up with my own fork that's never merged, but obviously that kind of forking can mean my version drifts farther and farther away from the trunk, so I want to check with the community here before I proceed.
from graphdiff.
Hi, I had a few hours this afternoon so I decided to give it a go. I like the suggestions, I've put in a PR to show the proposed solution. It's not finished but just an early look to get thoughts and suggestions. Can you take a look? https://github.com/refactorthis/GraphDiff/pull/58
cheers.
p.s. should also mention I'm thinking of adding a class whicih will allow you to register the default mappings for aggregates at app start which will be the default if provided no mapping configuration to UpdateGraph() (sort of like fluent api) There is also a Select for aggregates in the POC.
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.