Ejemplo n.º 1
0
        public EntityRowComparer(List <Tuple <PropertyDescriptor, int> > keys)
        {
            List <Tuple <PropertyDescriptor, int, IDbValueReader> > keyList = new List <Tuple <PropertyDescriptor, int, IDbValueReader> >(keys.Count);

            for (int i = 0; i < keys.Count; i++)
            {
                var            tuple         = keys[i];
                IDbValueReader dbValueReader = DataReaderConstant.GetDbValueReader(tuple.Item1.PropertyType);

                keyList.Add(new Tuple <PropertyDescriptor, int, IDbValueReader>(tuple.Item1, tuple.Item2, dbValueReader));
            }

            this._keys      = keyList;
            this._keyValues = new object[keys.Count];
        }
Ejemplo n.º 2
0
        static Action <TEntity, IDataReader> GetMapper <TEntity>(PrimitivePropertyDescriptor propertyDescriptor, int ordinal)
        {
            var dbValueReader = DataReaderConstant.GetDbValueReader(propertyDescriptor.PropertyType);

            Action <TEntity, IDataReader> mapper = (TEntity entity, IDataReader reader) =>
            {
                object value = dbValueReader.GetValue(reader, ordinal);
                if (value == null || value == DBNull.Value)
                {
                    throw new ChloeException($"Unable to get the {propertyDescriptor.Property.Name} value from data reader.");
                }

                propertyDescriptor.SetValue(entity, value);
            };

            return(mapper);
        }
Ejemplo n.º 3
0
 public PrimitiveObjectActivator(Type primitiveType, int readerOrdinal)
 {
     this._primitiveType = primitiveType;
     this._readerOrdinal = readerOrdinal;
     this._dbValueReader = DataReaderConstant.GetDbValueReader(primitiveType);
 }