コード例 #1
0
        /// <summary>
        ///     Gets or sets the <see cref="TEntity" /> with the specified index.
        /// </summary>
        public TEntity this[int index]
        {
            get
            {
                /////
                // Struct type always returns an instance.
                /////
                IMutableIdKey match = _tracker.ElementAt(index);

                return(Entity.Get <TEntity>(match.Key));
            }
            set
            {
                Precheck( );

                /////
                // Struct type always returns an instance.
                /////
                IMutableIdKey match = _tracker.ElementAt(index);

                _tracker.Remove(match);

                if (value != null)
                {
                    _tracker.Add((( IEntityInternal )value).MutableId);
                }
            }
        }
コード例 #2
0
        public void Execute(CreateProductTypeCommand command)
        {
            var productType = new ProductType()
            {
                Name       = command.Name,
                Attributes = command.Attributes.ToList()
            };

            _productTypeRepository.Add(productType);
            _productTypeRepository.Save();

            _changeTracker.Add(productType);
        }
コード例 #3
0
        /// <summary>
        ///     Adds the specified item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <exception cref="RelationshipInstanceException"></exception>
        public void Add(TEntity item)
        {
            /////
            // Input validation.
            /////
            if (item == null)
            {
                return;
            }

            Precheck( );

            if (_tracker.All(p => p.Key != item.Id))
            {
                _tracker.Add((( IEntityInternal )item).MutableId);
            }
        }