开发者

Passing full entities to repository or just the ID`s to delete them?

I just asked myself is it real开发者_如何学运维ly needed to pass the whole List SelectedCustomers to the delete method of the Repository like:

_customerRepo.DeleteCustomers(SelectedCustomers);

Would it not be better to pass just the Id`s of the customers to be deleted like

List<int> SelectedCustomerIDs = GetSelectedCustomersIDs(SelectedCustomers);
_customerRepo.DeleteCustomers(SelectedCustomerIDs);

I am not using an ORMapper which surely accepts only full entities to acceptchanges on or to remove it from the context.

I am using sqlite so I thought passing a List of int values is faster/less Ram than passing a List of entities.

What do you think?


The objects are already in memory and you are not copying them when passing them to the repository, but only the references to them. So, you will not be saving on memory (unless your repository is on a different server).

So long as in your repository you are just using the IDs to pass to the database, you should be fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜