This project is read-only.

QueryHandler<TEntity>:Object must implement IConvertible



I implement my CustomEntityFactory, so when I use QuerySingle<TEntityInterface>()
I can create the Entity by my CustomerEntityFactory

So I change the code of QueryHandler<TEntity> to support I needs

If use the origin code , use QuerySingle<TEntityInterface>() will throw a excepiton Object must implement IConvertible

Please consider joining these codes
 public QueryHandler(DbCommandData data)
            _data = data;
            if (typeof(TEntity) == typeof(object) || typeof(TEntity) == typeof(ExpandoObject))
                _typeHandler = new QueryDynamicHandler<TEntity>(data);
            else if (typeof(TEntity) == typeof(DataTable))
                _typeHandler = new QueryDataTableHandler<TEntity>(data);
            else if (ReflectionHelper.IsCustomEntity<TEntity>())
                _typeHandler = new QueryCustomEntityHandler<TEntity>(data);
            /***************************************the code*******************************************/
            else if (data.Context.Data.EntityFactory.GetType() != typeof(EntityFactory))
                _typeHandler = new QueryCustomEntityHandler<TEntity>(data);
                _typeHandler = new QueryScalarHandler<TEntity>(data);
this is the code of my entityfactory
public class CustomEntityFactory : IEntityFactory
            public object Create(Type type)
                if (!type.IsInterface)
                    throw new Exception("my EntityFactory 非接口类型");

                var implType = GetImplTypeMethod(type);  //GetImplTypeMethod is Pseudocode

                return Activator.CreateInstance(implType);


when I use my CustomEntityFactory, the real type is a subclass of the the query type

but the automap use ReflectionHelper.GetProperties(itemType) to get the properties of the query type.
so if the subclass has some of the properties of the query type does not, automap will miss these properties

so I use the code like this
internal class AutoMapper
        private readonly DbCommandData _dbCommandData;
        //private readonly Dictionary<string, PropertyInfo> _properties;  //__delete by me__
        private readonly List<DataReaderField> _fields;
        private readonly System.Data.IDataReader _reader;

        //__should remove the  parameter  named itemType__
        internal AutoMapper(DbCommandData dbCommandData, Type itemType)
            _dbCommandData = dbCommandData;
            _reader = dbCommandData.Reader.InnerReader;
            //_properties = ReflectionHelper.GetProperties(itemType); //__delete by me__
            _fields = DataReaderHelper.GetDataReaderFields(_reader);

        public void AutoMap(object item)
            // add by me  :__use the real type__ 
            var _properties = ReflectionHelper.GetProperties(item.GetType());

            foreach (var field in _fields)