-
-
Notifications
You must be signed in to change notification settings - Fork 158
Make SaveChanges call configurable #614
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
Comments
Thanks for opening up an issue and your feedback @crgolden I have been considering to add such With respect to the inability to override virtual methods: it is still on the list to reconsider which helper methods should be exposed. Note that compared to v3 the amount of helper methods have significantly increased and this is due to the a lot of bug fixes and additions to comply with the json:api spec (eg central stuff like complete replace through patch wasn't supported: #530). On one side I realise that exposing them will greatly contribute extensibility: I have noticed myself during beta-testing that porting my custom services was a bit tedious. On the other hand I am hesitant because these are really just internals of the framework that are more volatile, and exposing them would require us to ensure backward compatibility. Possibly we could clearly state that these helper methods are internals and no backward compatibility is guaranteed. I believe EF Core did that with some of their internals, however I'm not sure if they bumped their major version when changing such internals Thoughts are welcome. |
Thanks for the response.
I agree with you in that regard. As far as eager loading with I think the best approach would be to add bulk operations. Using the EFCore.BulkExtensions or the MongoDB C# driver, for instance, this is possible. I made a simple
That is a thoughtful approach and I appreciate that. Ultimately, I think providing bulk operations would address all my concerns. I often am inserting hundreds of records at once and doing a save on each one is really a deal-breaker. |
I'm not sure if other ORMs provide clearly defined APIs to sideload data like EF Core does: probably not all of them. But even if they don't, one could still implement the
Did you use the json:api bulk extension in v3? It is removed right now but we are planning on adding it back ASAP because it indeed is really useful
I would love to learn more about how you're using mongodb with JADNC as it could provide a good starting point for a future |
As of now, I haven't been able to figure out how to keep the Authorization working. As you can imagine, that is a big problem in any production-level application... I did notice that this package bypasses it completely, and suggests using Resource Hooks instead. So I've been trying to use v4 for that feature. But so far I haven't been able to get the Resource Hooks working properly, either. I made another issue about that: #615 Thanks! |
I'm unsure how the json:api bulk extension is helpful to solving the authorization problem. Either way, I'll look into that issue right now |
Description
Right now,
SaveChangesAsync
is being called on everyCreateAsync
,UpdateAsync
, andDeleteAsync
call. As such, these methods actually do two different things:EntityState
on theEntityEntry
toAdded
,Modified
, orDeleted
.Proposal:
public virtual async Task<int> SaveChangesAsync(TResource entity)
method that actually does the saving.CreateAsync
,UpdateAsync
, andDeleteAsync
methods calledbool saveChanges = true
that could be set tofalse
.These changes would make the methods less expensive for bulk operations.
As an aside, I thought perhaps I would just override these methods and have them do everything except the saving. But they have become even more difficult to override in version 4. Suddenly, many of the
protected
methods they use have becomeprivate
. It is somewhat confusing to allow the methods to be overriden by marking themvirtual
, but to then restrict the accessibility of all the helper methods they use toprivate
....
Environment
The text was updated successfully, but these errors were encountered: