public void EditTopics(int id, IEnumerable<int> topics) { var allTopics = _Db.TopicFeatures.Where(tf => tf.FeatureId == id).AsEnumerable(); var deletedTopics = allTopics.Where(tf => !topics.Contains(tf.TopicId)); var addTopics = topics.Where(i => !allTopics.Select(t => t.TopicId).Contains(i)); _Db.TopicFeatures.DeleteAllOnSubmit(deletedTopics); foreach (var topic in addTopics) { var tf = new TopicFeature { FeatureId = id, TopicId = topic }; _Db.TopicFeatures.InsertOnSubmit(tf); } _Db.SubmitChanges(); }
private void detach_TopicFeatures(TopicFeature entity) { this.SendPropertyChanging(); entity.Topic = null; }
private void attach_TopicFeatures(TopicFeature entity) { this.SendPropertyChanging(); entity.Topic = this; }
partial void DeleteTopicFeature(TopicFeature instance);
partial void UpdateTopicFeature(TopicFeature instance);
partial void InsertTopicFeature(TopicFeature instance);