C# gRPG EF6 concurrency (rowversion)

15 views
Skip to first unread message

Smellblaster

unread,
Jun 16, 2020, 6:06:53 AM6/16/20
to grpc.io
Hello!

Usually I solve concurrency with EF6 so I add Timestamp (rowversion) column to all my tables.
When I try to update value in database I just need to check if value in this column is still the same.

Now I want to move CRUD operations to gRPC service.

I have 2 methods
- User GetUser(int id);
- UpdateUser(id, User u)

User is my model and is not directly mapped to Entity (so there is no rowversion field in my model).
Well. First idea that comes to my mind is to add this rowversion field to model also.

Is this correct approach or is there a better way.

Thanks

Eric Anderson

unread,
Jun 17, 2020, 10:55:44 AM6/17/20
to Smellblaster, grpc.io
What you're dealing with is very similar to etags. The Google Cloud API design patterns suggests "an API should include a string field etag in the resource definition." Looking at a few examples, you can see the pattern: User would have a rowversion field that would be set when returned by the service. When being passed to the service to be modified, the field would be set to the old version.

That approach is probably pretty natural in the code, as the client could do a get(), modify the proto in-place, and then a set(). It wouldn't even have to copy the rowversion explicitly.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/db8d097e-fa8c-42e8-9b6c-5ad0f114e817o%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages