static void DeleteUserSposorTopic(EditorsEntities entity, int TopicId, int UserId) { // First need to Get and delete SubTopics in the Topic which is going to Delete var Subtopics = (from s in entity.SubTopics where s.TopicID == TopicId && (((s.Type == 2) && s.UserID == UserId) || s.Type == 3) select s.SubTopicID).ToList(); foreach (var SubTopicId in Subtopics) { DeleteUserSubTopic(entity, SubTopicId, UserId); } entity.lib_RemoveSponsorTopic(UserId, TopicId); entity.SaveChanges(); }