예제 #1
0
        public void DeleteNews(News news)
        {
            using (ConfigurationDataContext context = new ConfigurationDataContext(Utility.GetConnectionString(configurationDataContext)))
            {
                var newsEntity = from item in context.News
                                 where item.NewsID == news.NewsID
                                 select item;

                News entity = newsEntity.SingleOrDefault();

                if (entity != null)
                {
                    context.DeleteObject(entity);
                    context.SaveChanges();
                }
            }
        }
예제 #2
0
        public string DeleteFile(File file)
        {
            using (ConfigurationDataContext context = new ConfigurationDataContext(Utility.GetConnectionString(configurationDataContext)))
            {
                var files = from item in context.Files
                            where item.FileID == file.FileID
                            select item;

                File entity = files.FirstOrDefault();

                if ((entity != null))
                {
                    context.DeleteObject(entity);
                    context.SaveChanges();
                }
                return entity.FileName;
            }
        }
예제 #3
0
        public void DeleteUser(User user)
        {
            using (ConfigurationDataContext context = new ConfigurationDataContext(Utility.GetConnectionString(configurationDataContext)))
            {
                var users = from item in context.Users
                            where item.UserID == user.UserID
                            select item;

                User entity = users.SingleOrDefault();

                if (entity != null)
                {
                    context.DeleteObject(entity);
                    context.SaveChanges();
                }
            }
        }