如何在 ASP.NET Boilerplate MVC 中删除实体列表而不使用循环?
目前,我使用:
foreach (var data in sampleDataList)
{
_iRepositorySampleData.Delete(data);
}
但我不想使用循环来删除多个实体。
最佳答案
ASP.NET Boilerplate 的 IRepository
不提供开箱即用的 RemoveRange
:
ASP.NET Boilerplate is designed to be independent from a particular ORM (Object/Relational Mapping) framework or another technique to access a database.1
积压中的功能请求:
目前,还没有太多进展,因为它已经成为可能,因此几乎没有什么附加值。
EF 核心
// using Abp.EntityFrameworkCore.Repositories;
repository.GetDbContext().RemoveRange(sampleDataList);
EF6
// using Abp.EntityFramework.Repositories;
var type = sampleDataList.GetType().GetGenericArguments().Single();
repository.GetDbContext().Set(type).RemoveRange(sampleDataList);
关于c# - ASP.NET 样板中的 DeleteRange 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49122183/