public override EntityKey Create(
            IEntityType entityType, IReadOnlyList<IProperty> properties, IValueReader valueReader)
        {
            var components = new object[properties.Count];

            for (var i = 0; i < properties.Count; i++)
            {
                var index = properties[i].Index;

                if (valueReader.IsNull(index))
                {
                    return EntityKey.InvalidEntityKey;
                }

                var value = _boxedValueReaders[i].ReadValue(valueReader, index);

                if (Equals(value, _sentinels[i]))
                {
                    return EntityKey.InvalidEntityKey;
                }

                components[i] = value;
            }

            return new CompositeEntityKey(entityType, components);
        }
        public override EntityKey Create(
            IEntityType entityType, IReadOnlyList <IProperty> properties, IValueReader valueReader)
        {
            var components = new object[properties.Count];

            for (var i = 0; i < properties.Count; i++)
            {
                var index = properties[i].Index;

                if (valueReader.IsNull(index))
                {
                    return(EntityKey.InvalidEntityKey);
                }

                var value = _boxedValueReaders[i].ReadValue(valueReader, index);

                if (Equals(value, _sentinels[i]))
                {
                    return(EntityKey.InvalidEntityKey);
                }

                components[i] = value;
            }

            return(new CompositeEntityKey(entityType, components));
        }
Пример #3
0
        public override EntityKey Create(IEntityType entityType, IReadOnlyList <IProperty> properties, IValueReader valueReader)
        {
            Check.NotNull(entityType, "entityType");
            Check.NotNull(properties, "properties");
            Check.NotNull(valueReader, "valueReader");

            return(valueReader.IsNull(properties[0].Index)
                ? EntityKey.NullEntityKey
                : new SimpleEntityKey <TKey>(entityType, valueReader.ReadValue <TKey>(properties[0].Index)));
        }
Пример #4
0
        public virtual void PropagateResults([NotNull] IValueReader reader)
        {
            Check.NotNull(reader, "reader");

            // TODO: Consider using strongly typed ReadValue instead of just <object>
            // Issue #771
            // Note that this call sets the value into a sidecar and will only commit to the actual entity
            // if SaveChanges is successful.
            var columnOperations = ColumnModifications.Where(o => o.IsRead).ToArray();

            for (var i = 0; i < columnOperations.Length; i++)
            {
                columnOperations[i].Value = reader.IsNull(i) ? null : reader.ReadValue <object>(i);
            }
        }
Пример #5
0
        public override EntityKey Create(
            IEntityType entityType, IReadOnlyList <IProperty> properties, IValueReader valueReader)
        {
            var index = properties[0].Index;

            if (!valueReader.IsNull(index))
            {
                var value = valueReader.ReadValue <TKey>(index);
                if (!EqualityComparer <TKey> .Default.Equals(value, _sentinel))
                {
                    return(new SimpleEntityKey <TKey>(entityType, value));
                }
            }

            return(EntityKey.InvalidEntityKey);
        }
Пример #6
0
        public ShadowStateEntry(
            [NotNull] DbContextConfiguration configuration,
            [NotNull] IEntityType entityType,
            [NotNull] IValueReader valueReader)
            : base(configuration, entityType)
        {
            Check.NotNull(valueReader, "valueReader");

            _propertyValues = new object[valueReader.Count];

            for (var i = 0; i < valueReader.Count; i++)
            {
                // TODO: Consider using strongly typed ReadValue instead of always object
                _propertyValues[i] = valueReader.IsNull(i) ? null : valueReader.ReadValue <object>(i);
            }
        }
Пример #7
0
        private object[] ExtractShadowValues(IValueReader valueReader)
        {
            var shadowValues = new object[EntityType.ShadowPropertyCount];

            var properties = EntityType.Properties;

            for (var i = 0; i < properties.Count; i++)
            {
                var property = properties[i];
                if (!property.IsClrProperty)
                {
                    // TODO: Consider using strongly typed ReadValue instead of always object
                    shadowValues[property.ShadowIndex] = valueReader.IsNull(i) ? null : valueReader.ReadValue <object>(i);
                }
            }

            return(shadowValues);
        }
        public ShadowStateEntry(
            [NotNull] StateManager stateManager,
            [NotNull] IEntityType entityType,
            [NotNull] StateEntryMetadataServices metadataServices,
            [NotNull] IValueReader valueReader)
            : base(stateManager, entityType, metadataServices)
        {
            Check.NotNull(valueReader, "valueReader");

            _propertyValues = new object[valueReader.Count];

            for (var i = 0; i < valueReader.Count; i++)
            {
                // TODO: Consider using strongly typed ReadValue instead of always object
                // Issue #738
                _propertyValues[i] = valueReader.IsNull(i) ? null : valueReader.ReadValue <object>(i);
            }
        }
Пример #9
0
        private object[] ExtractShadowValues(IValueReader valueReader)
        {
            var shadowValues = new object[EntityType.ShadowPropertyCount];

            var properties = EntityType.Properties;
            for (var i = 0; i < properties.Count; i++)
            {
                var property = properties[i];
                if (!property.IsClrProperty)
                {
                    // TODO: Consider using strongly typed ReadValue instead of always object
                    shadowValues[property.ShadowIndex] = valueReader.IsNull(i) ? null : valueReader.ReadValue<object>(i);
                }
            }

            return shadowValues;
        }
 public virtual object ReadValue(IValueReader valueReader, int index)
 => valueReader.IsNull(index) ? null : (object)valueReader.ReadValue <TValue>(index);
Пример #11
0
 public bool IsNull(int index)
 {
     return(_valueReader.IsNull(_offset + index));
 }
 public virtual bool IsNull(int index) => _valueReader.IsNull(_offset + index);