1
I have a method that deletes a version of a file according to the version of the file passed, 1 file may have many versions, and I wanted to delete all versions, I managed to delete only 1 version of a particular file. But I want to delete all versions of a particular file, see:
internal void ApagarArquivoVersao(Model.ArquivoVersao arquivoVersao)
{
using (var ctx = new TESTEntities())
{
var fileVer = ctx.ARQUIVO_VERSAO.FirstOrDefault(a => a.ARQUIVO_GUID == arquivoVersao.ARQUIVO_GUID);
if (fileVer == null)
throw new ArquivoException("Arquivo não encontrado");
ctx.Entry(fileVer).State = System.Data.EntityState.Deleted;
ctx.SaveChanges();
}
}
The above method deletes only 1 version of the requested file, as it would look to erase all versions of the same ARQUIVO_GUID?
What version of EF are you using? if it is EF6 you can use the method . Removerange()
– Tobias Mesquita