void ItemsByTagView_Loaded(object sender, RoutedEventArgs e1) { ListBoxOne.SelectedIndex = -1; if (selectedTag == null) { this.selectedTag = this.DataContext as Tag; } else { this.DataContext = selectedTag; } ListBoxOne.ItemsSource = from items in SyncContextInstance.Context.ItemCollection.Where((e) => e.Status < 2) join t2i in SyncContextInstance.Context.TagItemMappingCollection.Where((e) =>e.TagID.Equals(selectedTag.ID)) on items.ID equals t2i.ItemID select items; }
public void DeleteTag(Tag entity) { base.DeleteItem<Tag>(entity); }
public void AddTag(Tag entity) { base.AddItem<Tag>(entity); }
public List<Tag> GetAllTags() { var tags = new List<Tag>(); using (var command = new SqlCeCommand()) { command.Connection = GetSqlCeConnection(); command.CommandText = GET_ALL_TAGS; SqlCeDataReader reader = command.ExecuteReader(); while (reader.Read()) { var t = new Tag { ID = (int) reader["ID"], Name = reader["Name"] as string, ServiceMetadata = new OfflineEntityMetadata() { IsTombstone = false, Id = reader["_MetadataID"] as string } }; tags.Add(t); } } return tags; }
/// <summary> /// Removes the requested tag item mapping for the specified tag and item /// </summary> /// <param name="item">Item for which to remove the tag mapping</param> /// <param name="tag">Tag for which to remove the mapping</param> public void RemoveTagMapping(Item item, Tag tag) { // find the mapping TagItemMapping tim = (from t in context.TagItemMappingCollection where t.ItemID == item.ID && t.TagID == tag.ID select t).FirstOrDefault(); if (tim != default(TagItemMapping)) { // delete it from the context. context.DeleteTagItemMapping(tim); } }
/// <summary> /// Adds a new tag to item mapping. /// </summary> /// <param name="item">Item to which a tag is being mapped</param> /// <param name="tag">Tag to which an item is being mapped</param> public void AddTagMapping(Item item, Tag tag) { // Here we ensure that the referential integrity is correct. // In the UI, there is no way to add a duplicate mapping, so // uniqueness is insured. Other applications may have to do // an explicit check here. TagItemMapping tim = new TagItemMapping() { ItemID = item.ID, TagID = tag.ID, UserID = UserID }; context.AddTagItemMapping(tim); }