Ejemplo n.º 1
0
        public void PutNextVersion(UpdateDocument updateDoc, object entity)
        {
            var    version = this.Accessor.GetValue(entity);
            object nextVersion;

            var type = this.Descriptor.Property.PropertyType;

            if (type == typeof(int))
            {
                nextVersion = (int)version + 1;
            }
            else if (type == typeof(long))
            {
                nextVersion = Int64Version.GetCurrent();
            }
            else if (type == typeof(DateTime))
            {
                nextVersion = DateTimeVersion.GetCurrent();
            }
            else
            {
                throw new NotSupportedException(String.Format("Don't support type {0} as version.", type));
            }

            ((IPropertyUpdateOperator)this).PutConstantUpdate(updateDoc, nextVersion);
        }
Ejemplo n.º 2
0
        public void PutVersionUpdate(BsonDocument updateDoc)
        {
            var optr = (IPropertyUpdateOperator)this;

            var type = this.Descriptor.Property.PropertyType;

            if (type == typeof(int))
            {
                optr.PutAddUpdate(updateDoc, 1);
            }
            else if (type == typeof(long))
            {
                optr.PutConstantUpdate(updateDoc, Int64Version.GetCurrent());
            }
            else if (type == typeof(DateTime))
            {
                optr.PutConstantUpdate(updateDoc, DateTime.UtcNow);
            }
            else
            {
                throw new NotSupportedException(String.Format("Don't support type {0} as version.", type));
            }
        }