private T ExecuteDataReader <T>(DbDataReader dataReader)
            where T : class
        {
            var len = dataReader.FieldCount;

            EntityProxy <T> entityProxy = EntityProxyManager.Instance.GetEntityProxy <T>();

            T result = entityProxy.CreateInstance() as T;

            for (var i = 0; i < len; i++)
            {
                string name     = dataReader.GetName(i);
                var    rawValue = dataReader.GetValue(i);

                try
                {
                    entityProxy.SetPropertyValue(result, name, rawValue);
                }
                catch (Exception)
                {
                    ThrowExceptionUtil.ThrowMessageException("setpropertyerror.name:{0} value:{1}".FormatWith(name, rawValue));
                }
            }

            return(result);
        }
Exemple #2
0
        public TableSchema GetTableSchema(string tableName)
        {
            TableSchema result = null;

            try
            {
                result = CacheManager.Instance.GetEntity <TableSchema, string>(
                    Constants.BeeDataTableSchemaCacheCategory + dbDriver.ConnectionName,
                    tableName, TimeSpan.FromHours(1), tableNamePara =>
                {
                    return(dbDriver.GetTableSchema(tableNamePara));
                });
            }
            catch (KeyNotFoundException)
            {
                ThrowExceptionUtil.ThrowMessageException("表中含有不支持的数据类型");
            }
            catch (Exception)
            {
                throw;
            }

            return(result);
        }