0
I have the following situation with a method of deleting directory:
internal void DeleteDiretorio(Model.Diretorio diretorio)
{
using (var ctx = new TESTEntities())
{
var dir = ctx.DIRETORIO.FirstOrDefault(a => a.DIRETORIO_GUID == diretorio.DIRETORIO_GUID);
if (dir == null)
throw new ArquivoException("Diretorio não encontrado");
ctx.Entry(dir).State = System.Data.EntityState.Deleted;
ctx.SaveChanges();
}
}
This method is to delete according to the id,but Directory it has a list of files so it does not allow to delete, as would be this method in EF to delete with all files linked to the directory?
In case of relationships between entities, delete must be by cascade.
– pnet
And then how would you look in my case Using EF?
– War Lock