I am using NPoco, in Umbraco, and want to delete multiple records. I have tried this but although it returns the number of records, they are not actually deleted from the database. What am I doing wrong?
public void DeleteArticleViewsById(IEnumerable<int> idList)
{
using var scope = _scopeProvider.CreateScope();
var x = scope.Database.DeleteMany<ManualViewEntity>()
.Where(x => x.Pk.In(idList))
.Execute();
scope.Complete();
}
ManualViewEntity is defined as
[TableName("ManualView")]
[PrimaryKey(nameof(ManualViewEntity.Pk), AutoIncrement = true)]
[ExplicitColumns]
public class ManualViewEntity
{
[Ignore]
public static string TableName => "ManualView";
[Column("pk")]
[PrimaryKeyColumn(AutoIncrement = true, IdentitySeed = 1)]
public int Pk { get; set; }
[Column("memberId")]
public int MemberId { get; set; }
[Column("articleId")]
public int ArticleId { get; set; }
[Column("viewDate")]
public DateTime ViewDate { get; set; }
}