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(); } } }
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; } }
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(); } } }