Exemplo n.º 1
0
        public ObjectID Read(IDataReader dataReader)
        {
            ArgumentUtility.CheckNotNull("dataReader", dataReader);

            if (dataReader.Read())
            {
                return((ObjectID)_idProperty.CombineValue(new ColumnValueReader(dataReader, _columnOrdinalProvider)));
            }
            else
            {
                return(null);
            }
        }
        public object CombineValue(IColumnValueProvider columnValueProvider)
        {
            ArgumentUtility.CheckNotNull("columnValueProvider", columnValueProvider);

            var value   = _valueProperty.CombineValue(columnValueProvider);
            var classID = (string)_classIDProperty.CombineValue(columnValueProvider);

            if (value == null)
            {
                if (classID != null)
                {
                    throw new RdbmsProviderException(
                              string.Format(
                                  "Incorrect database value encountered. The value read from '{0}' must contain null.",
                                  string.Join(", ", _classIDProperty.GetColumns().Select(c => c.Name))));
                }

                return(null);
            }

            if (classID == null)
            {
                throw new RdbmsProviderException(
                          string.Format(
                              "Incorrect database value encountered. The value read from '{0}' must not contain null.",
                              string.Join(", ", _classIDProperty.GetColumns().Select(c => c.Name))));
            }

            return(new ObjectID(classID, value));
        }
        public object CombineValue(IColumnValueProvider columnValueProvider)
        {
            ArgumentUtility.CheckNotNull("columnValueProvider", columnValueProvider);

            var value = _valueProperty.CombineValue(columnValueProvider);

            if (value == null)
            {
                return(null);
            }
            return(new ObjectID(_classDefinition, value));
        }
        public object CombineValue(IColumnValueProvider columnValueProvider)
        {
            ArgumentUtility.CheckNotNull("columnValueProvider", columnValueProvider);

            var value = _serializedIDProperty.CombineValue(columnValueProvider);

            if (value == null)
            {
                return(null);
            }
            return(ObjectID.Parse((string)value));
        }
        private Tuple <ObjectID, object> GetTimestampTuple(IColumnValueProvider columnValueProvider)
        {
            var objectIDValue = (ObjectID)_idProperty.CombineValue(columnValueProvider);

            if (objectIDValue == null)
            {
                return(null);
            }

            var timestampValue = _timestampProperty.CombineValue(columnValueProvider);

            return(Tuple.Create(objectIDValue, timestampValue));
        }
        protected virtual DataContainer CreateDataContainerFromReader(IDataReader dataReader, ColumnValueReader columnValueReader)
        {
            ArgumentUtility.CheckNotNull("dataReader", dataReader);

            var id = (ObjectID)_idProperty.CombineValue(columnValueReader);

            if (id == null)
            {
                return(null);
            }

            var timestamp = _timestampProperty.CombineValue(columnValueReader);

            var dataContainer = DataContainer.CreateForExisting(
                id,
                timestamp,
                pd => pd.StorageClass == StorageClass.Persistent ? ReadPropertyValue(pd, columnValueReader, id) : pd.DefaultValue);

            _dataContainerValidator.Validate(dataContainer);

            return(dataContainer);
        }