public async Task Test_QueryAssetBrokerInfoAsync() { using (IDbConnection connection = new SqlConnection(ConnectionString)) { const string sql = @"select Id as 'BrokerId', Name, Code from AssetBrokers where deleted = 0 order by CreatedTime desc" ; DataProviderExtension.SetTypeMap(typeof(AssetBrokerInfo)); var brokers = await connection.QueryAsync <AssetBrokerInfo>(sql).ConfigureAwait(false); var result = brokers.ToArray(); foreach (var assetBrokerInfo in result) { _output.WriteLine(assetBrokerInfo.Name); } } }
public async Task TestCustomeComplexType() { DataProviderExtension.SetTypeMap(new[] { typeof(DecimalRange), typeof(LifeOfLoan), typeof(FundingBrokerSetting), typeof(InternalRiskControlSetting), typeof(IdName), typeof(GuaranteeInfo), }); using (var assetConnection = new SqlConnection(ConnectionString)) { string sql = $@"SELECT [CreatedTime] ,[Id] ,[Version] ,[AssetBrokerId] ,[AssetBrokerCode] ,[Name] ,[Code] ,[BorrowerType] ,[Type] ,[AuditStatus] ,[Enabled] ,[Remark] ,[RepaymentMethod] ,[InterestRate] ,[InterestBearingPeriod] ,[OverduePenaltyInterestRate] ,[PrepaymentPenaltyInterestRate] ,[AmountRange_From] ,[AmountRange_To] ,[LifeOfLoan_TermsValue] ,[LifeOfLoan_Unit] ,[FeeRate_PlatformFeeRate_From] ,[FeeRate_PlatformFeeRate_To] ,[FeeRate_AssetBrokerFeeRate_From] ,[FeeRate_AssetBrokerFeeRate_To] ,[FeeRate_FundingBrokerFeeRate_From] ,[FeeRate_FundingBrokerFeeRate_To] ,[FundingBrokerSetting_FundingBrokerId] ,[FundingBrokerSetting_NeedWithholding] ,[InternalRiskControlSetting_NeedAudit] ,[InternalRiskControlSetting_NeedSystemAutoAudit] ,[InternalRiskControlSetting_NeedManualReviewAfterSystemMissing] ,[InternalRiskControlSetting_AuditRuleGroup_Id] ,[InternalRiskControlSetting_AuditRuleGroup_Name] ,[InternalRiskControlSetting_ScoreRuleGroup_Id] ,[InternalRiskControlSetting_ScoreRuleGroup_Name] ,[Guarantee_GuaranteeId] ,[Guarantee_Type] FROM [BrokerLoanProducts] where Deleted = 0"; var assetBroker = await assetConnection.QueryAsync(sql, _types, _map, splitOn : _splitOn).ConfigureAwait(false); } }