public void UpdateDatabase(SurveyDbContext surveyEntities) { if (String.IsNullOrEmpty(Soru) || Choices.Count(x => !String.IsNullOrEmpty(x.Yazı)) < 2) { surveyEntities.Choices.RemoveRange(surveyEntities.Choices.Where(x => x.QuestionId == Questionİd)); surveyEntities.Answers.RemoveRange(surveyEntities.Answers.Where(x => x.QuestionId == Questionİd)); surveyEntities.Questions.Remove(surveyEntities.Questions.First(X => X.QuestionId == Questionİd)); } else { foreach (var item2 in Choices) { if (String.IsNullOrEmpty(item2.Yazı)) { surveyEntities.Choices.Remove(surveyEntities.Choices.Single(x => x.ChoiceId == item2.ChoiceId)); } else { surveyEntities.Choices.Single(x => x.ChoiceId == item2.ChoiceId).Yazı = item2.Yazı; } } if (Soru.Length > 5) { surveyEntities.Questions.Single(x => x.QuestionId == Questionİd).Soru = Soru; } } }
public override int GetHashCode() { int hash = 0; foreach (Choice ch in Choices) { hash ^= ch.GetHashCode(); } hash = (~0xf & hash) | Choices.Count(); return(hash); }