private void detach_Ideas(Ideas entity) { this.SendPropertyChanging(); entity.Categories = null; }
private void attach_Ideas(Ideas entity) { this.SendPropertyChanging(); entity.Categories = this; }
partial void DeleteIdeas(Ideas instance);
partial void UpdateIdeas(Ideas instance);
partial void InsertIdeas(Ideas instance);
private void CreateIdea() { if (IdeaTitle.Text.Length > 250) { MessageBox.Show("Idea title is too long!"); } else if (IdeaContent.Text.Length > 3990) { MessageBox.Show("Sorry, idea content is too long!"); } else if (IdeaTitle.Text.Length > 0 && IdeaContent.Text.Length > 0) { using (IdeasContext ctx = new IdeasContext(IdeasContext.ConnectionString)) { ctx.CreateIfNotExists(); int CatId = (from p in ctx.Categories where p.Name == lpkCategories.SelectedItem.ToString() select p.Id).Single(); var idea = new Ideas() { Title = IdeaTitle.Text, Cat_id = CatId, Content = IdeaContent.Text }; ctx.Ideas.InsertOnSubmit(idea); ctx.SubmitChanges(); NavigationService.GoBack(); } } }