public int Delte(int TypeId) { using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; //Media_Types type_obj = (from x in dbContext.Media_Types where x.TypeId == TypeId select x).First(); Media_Types type_obj = dbContext.Media_Types.Single(x => x.TypeId == TypeId); dbContext.DeleteObject(type_obj); int i = dbContext.SaveChanges(); return i; } }
public int Delete(string UserId, int Idx, string Dir_Path) { using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; string filename = (from x in dbContext.Media_Topics where x.TopicId == Idx select x.Photo).SingleOrDefault(); if (filename != null && filename != string.Empty) module_obj.deleteFile(filename, Dir_Path); //Media_Topics topic_obj = (from x in dbContext.Media_Topics where x.TopicId == Idx select x).First(); Media_Topics topic_obj = dbContext.Media_Topics.Single(x => x.TopicId == Idx); dbContext.DeleteObject(topic_obj); int i = dbContext.SaveChanges(); return i; } }