-
-
Notifications
You must be signed in to change notification settings - Fork 158
Feature/fluent mapping #771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/fluent mapping #771
Conversation
Fluent has Precedence when combined with Annotations
Demonstrate Fluent Resource Mapping
what exactly is being added here? Why are there no tests? |
I've talked with Bart about adding Fluent Mapping for Resources as an alternative for Annotations |
@yaniv-yechezkel Correct me if I'm wrong, but I understood that the goal here is to have no NuGet reference to JADNC from your Models project (onion architecture). Using fluent mappings would enable that. My first thought is that I like the general approach you have taken. There's many little things to improve (including we need to have tests) which we can go over at a later time. For now, the AppDomain scanning looks expensive and I think it should accept a list of assemblies/types instead, coming from Startup.Configure method. Thanks for your efforts so far! @maurei thoughts? |
Thanks @bart-degreed. Yes, The main goal it to keep the Domain clean. Providing a list of Assemblies would be much better, and Tests... of course! Sure. It's a great project. |
Enable Registration of specific Resource Mappings
@bart-degreed I've managed to handle Resource Mapping registration during Discovery. |
About IIdentifiable: see my comment at #730 (comment). I've created an issue (#776) for the design this PR is supposed to implement. I'm curious about your opinion, so feel free to add comments/remarks/questions there. |
Based on my proposal, I don't think we need to have assembly/type scanning at all. The building steps can simply be extracted into a separate class if the goal is to keep Startup.cs clean. |
From my understating, there's already assembly/type scanning happening. This is the discovery. |
You are correct that discovery also picks up resources, aside from services and definitions. This is all convention-based. I meant we should not add extra discovery steps (which you did at https://github.com/json-api-dotnet/JsonApiDotNetCore/pull/771/files#diff-fbd8f7ce570dc8180eb86d101f854b1dR249). |
I totally agree with you there should not be an extra step. |
I intended to reference this line in JsonApiApplicationBuilder: _services.TryAddSingleton<IResourceMappingService>(sp => new ResourceMappingService(_services)); |
Thanks. It is not a separate step. It is used in Discovery for registering the Resource Mappings provided from Startup, and then for resolving Resource Mapping when building the Graph. When Graph Builder is looking for defining Attributes, Relationships etc on a given Resource, it asks the Resource Service for available Mapping. At this stage Resource Mapping Service relies on them to already be registered on the Container... |
Added support for Fluent API for Resource Mapping
Including:
Resource Name
Attributes and Capabilities
Relationships
Eager Loads
Links
Extended EF Demo with Models and Resource Mappings