Inheritance: SmartDeviceProject1.SqlCeOfflineEntity
Esempio n. 1
0
        /// <summary>
        /// Adds a new item based on the model item passed in.
        /// </summary>
        /// <param name="modelItem"></param>
        public void AddItem(ModelItem modelItem)
        {
            // Retrieve the context item
            DefaultScope.Item newItem = modelItem.Item;

            // Parameter validation
            if (null == newItem)
            {
                throw new ArgumentNullException("newItem");
            }

            if (newItem.ID == null)
            {
                throw new ArgumentException("Item id is null");
            }

            // Ensure that the item id is unique
            DefaultScope.Item existingItem = (from s in context.ItemCollection
                                              where s.ID == newItem.ID
                                              select s).FirstOrDefault();

            if (existingItem != default(Item))
            {
                throw new ArgumentException("Item with the same id already exists");
            }

            // Add the new item to the context
            context.AddItem(newItem);
        }
Esempio n. 2
0
 public void DeleteItem(Item entity) {
     base.DeleteItem<Item>(entity);
 }
Esempio n. 3
0
 public void AddItem(Item entity) {
     base.AddItem<Item>(entity);
 }