private ExperimentManager() { _config = (MtelligentSection)ConfigurationManager.GetSection(sectionName); DataProviderFactory factory = new DataProviderFactory(_config); _visitProvider = factory.CreateProvider(); }
protected virtual IDataProvider CreateDataProvider() { IDataProvider result = null; if (ConfigurationClientData != null && ConfigurationGroupData != null && !string.IsNullOrEmpty(ConfigurationGroupData.DataGroup)) { result = DataProviderFactory.CreateProvider(ConfigurationGroupData.DataGroup, this.ConfigurationClientData.DataProvider); } if (result == null) { return(CreateDataProviderCore()); } return(result); }
static void DataReaderToEntity() { //创建方法 toEntityMethod = typeBuilder.DefineMethod("ToEntity", MethodAttributes.Public, typeof(object), new Type[] { typeof(IDataReader) }); ILGenerator il = toEntityMethod.GetILGenerator(); DbDriveFactories.SetFactory <MySql.Data.MySqlClient.MySqlClientFactory>(new MySQLTranslator().ProviderInvariantName); EntityConfigurationFactory.SetConfiguration(typeof(UserIL), typeof(UserEntityConfigurationIL)); IEntityMapper entityMapper = EntityMapperFactory.Instance.GetEntityMapper(typeof(UserIL)); IDataProviderFactory DataProviderFactory = new DataProviderFactory(); DataProviderFactory.AddDataSettings(getDefaultDataSetting()); IDataProvider dataProvider = DataProviderFactory.CreateProvider("test"); string sql = "SELECT Id,USERNAME,Age,Height,Six,ExtensionData,OrgId,TenantId,Address_CityId,Address_Street,ADDRESS_NUM,IsDeleted,DeleterUserId,DeletionTime,LastModificationTime,LastModifierUserId,CreationTime,CreatorUserId FROM TEST_USER WHERE Id = 13873372135800832 ORDER BY Id ASC"; dataProvider.ExecuteReader(new Core.Data.SqlStatement(CommandType.Text, sql), (reader) => { while (reader.Read()) { UserIL User = (UserIL)ToEntity(reader); //Maple.Core.Reflection.TypeDeserializerEmit.CreateDataReaderDeserializer2(entityMapper, reader); Maple.Core.Reflection.TypeDeserializerEmit.BuildFunction(entityMapper, reader, il); try { UserIL obj = (UserIL)Maple.Core.Reflection.TypeDeserializerEmit.CreateDataReaderDeserializer(entityMapper, reader)(reader); } catch { } //DataReaderDeserializer deserializer = entityMapper.GetDataReaderDeserializer(reader); //obj = (User)deserializer(reader); break; } }); }