So usually I see Create() or Add() methods in a repository pattern with a return type of void. It's not clear to me why would you not want the generated Id returned, and in case you needed it, how this signature would be able to retrieve the generated Id.
In case of void, if I needed the Id after creating, I would need to call Create() then do a Get() query immediately based on some other unique field of the entity (hopefully there is) just to get the Id.
I'm sure there's a good reason why most chooses void as the return type, can someone please enlighten me.
Aucun commentaire:
Enregistrer un commentaire