I have a method that deletes a version of a file according to the last file version, 1 file can have many versions, and I wanted to delete all versions, I was able to delete only 1 version of a particular file. 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 erases only 1 version of the requested file, how would it be to erase all versions of the same GUID_FILE?