The IRepository interface defined some CURD method, such as Insert, Update, Delete......, all of them only accept a single entity parameter, why not provide the method which could accept a collection of entity?
So that, if we want to execute a bulk action, such as, update or delete, then we get a collection of the entity, via for each iterate the item and update it, at the last execute the _appRepository.Update(IList<entity> entities) do a database action.
Why not provide these extensions? Is the Unit Of Work attribute applied on a application service default done the work? So, the method of an application service is a transaction? after the method executed, a transaction is executing then all database action done together?
A sample code I did:
var results = from r in _resultRepository.GetAllList()
.Where(r => r.EvaluationFormId == evaluationFormId)
select r;
foreach (var item in results)
{
_resultService.ChangeStatus(item);
}
but I want to do like below:
var results = from r in _resultRepository.GetAllList()
.Where(r => r.EvaluationFormId == evaluationFormId)
select r;
foreach (var item in results)
{
item.State = ResultStatus.Completed;
}
_resultService.Update(results);
1 Answer(s)
-
0
Hi,
We are not consedering to implement it in the near future. We might not implement it at all. Because, different database providers have different approaches. Also we think that this approach is not good for DDD development.
If you are using EntityFramework, you can take a look at this issue <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1021">https://github.com/aspnetboilerplate/as ... ssues/1021</a>.
I haven't tried any of them but you can use one of these libraries,
<a class="postlink" href="https://github.com/loresoft/EntityFramework.Extended">https://github.com/loresoft/EntityFramework.Extended</a> <a class="postlink" href="http://www.zzzprojects.com/entity-framework-bulk-insert">http://www.zzzprojects.com/entity-framework-bulk-insert</a>