コード例 #1
0
        public BoolResult DeleteTranslate(int idTranslate)
        {
            var translate = context.Translation
                            .Include(t => t.IdWordNavigation)
                            .ThenInclude(w => w.Translation)
                            .FirstOrDefault(t => t.IdTranslation == idTranslate);

            if (translate == null)
            {
                return(BoolResult.Error("Translate not found"));
            }
            context.Entry(translate).State = EntityState.Deleted;

            if (translate.IdWordNavigation.Translation.Count() == 1)
            {
                context.Entry(translate.IdWordNavigation).State = EntityState.Deleted;
            }
            context.SaveChanges();
            return(BoolResult.Ok(true));
        }