当前位置: 首页>>代码示例>>C#>>正文


C# SqlConnection.AutoQuery方法代码示例

本文整理汇总了C#中System.Data.SqlClient.SqlConnection.AutoQuery方法的典型用法代码示例。如果您正苦于以下问题:C# SqlConnection.AutoQuery方法的具体用法?C# SqlConnection.AutoQuery怎么用?C# SqlConnection.AutoQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.SqlClient.SqlConnection的用法示例。


在下文中一共展示了SqlConnection.AutoQuery方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: querying_class_referencing_subclass_retrieves_children

 public void querying_class_referencing_subclass_retrieves_children()
 {
     try
     {
         using (var connection = new SqlConnection())
         {
             var results = connection.AutoQuery<C, B>(new { CKey = 1 });
         }
     }
     catch (InvalidOperationException ioe)
     {
         CheckException(ioe);
     }
 }
开发者ID:oliverreid,项目名称:Dapper.SimpleLoad,代码行数:14,代码来源:InheritanceTests.cs

示例2: generates_correct_query_for_many_to_many_relationship

 public void generates_correct_query_for_many_to_many_relationship()
 {
     try
     {
         using (var connection = new SqlConnection())
         {
             var results = connection.AutoQuery<UserWithDepartmentsDto, SimpleDepartmentDto>(
                 new
                 {
                     UserKey = 1
                 });
         }
     }
     catch (InvalidOperationException ioe)
     {
         CheckException(ioe);
     }
 }
开发者ID:oliverreid,项目名称:Dapper.SimpleLoad,代码行数:18,代码来源:QueryGenerationTests.cs

示例3: generates_correct_query_with_custom_where_condition

 public void generates_correct_query_with_custom_where_condition()
 {
     try
     {
         using (var connection = new SqlConnection())
         {
             var results = connection.AutoQuery<PhoneNumberDto, CountryDto>(
                 new[] {"n", "c"},
                 "[c].[TelephoneCountryCode] = @CountryCode AND [n].[PhoneNumber] = @Number",
                 new
                 {
                     CountryCode = "44",
                     Number = "7779123456"
                 });
         }
     }
     catch (InvalidOperationException ioe)
     {
         CheckException(ioe);
     }
 }
开发者ID:oliverreid,项目名称:Dapper.SimpleLoad,代码行数:21,代码来源:QueryGenerationTests.cs

示例4: generates_correct_query_for_complex_types

        public void generates_correct_query_for_complex_types()
        {
            //var logger = 
            //SimpleSaveExtensions.Logger = //    TODO

            try
            {
                using (var connection = new SqlConnection())
                {
                    connection
                        .AutoQuery
                        <PhoneNumberDto, CountryDto, CurrencyCodeDto>(new
                            {
                                PhoneNumberKey = 1
                            });
                }
            }
            catch (InvalidOperationException ioe)
            {
                CheckException(ioe);
            }

            //  TODO: check the script
        }
开发者ID:oliverreid,项目名称:Dapper.SimpleLoad,代码行数:24,代码来源:QueryGenerationTests.cs

示例5: generates_correct_query_for_complex_merchant_dto

 public void generates_correct_query_for_complex_merchant_dto()
 {
     try
     {
         using (var connection = new SqlConnection())
         {
             var results = connection.AutoQuery<MerchantMasterDto>(
                 new[]
                 {
                     typeof (PhoneNumberDto),
                         typeof (CountryDto),
                     typeof (FaxNumberDto),
                         typeof (CountryDto),
                     typeof (ContactMasterDto),
                         typeof (EmailAddressMasterDto),
                         typeof (PhoneNumberDto),
                             typeof (CountryDto),
                         typeof (MobilePhoneNumberDto),
                             typeof (CountryDto),
                         typeof (SalutationDto),
                     typeof (MerchantDetailsDto),
                         typeof (TerminalModelDto),
                     typeof (AddressDto),
                         typeof (CountyDto),
                         typeof (PostCodeDetailsDto),
                         typeof (PostalDistrictNameDto)
                 },
                 new {MerchantGuid = Guid.Empty}).FirstOrDefault();
         }
     }
     catch (InvalidOperationException ioe)
     {
         CheckException(ioe);
     }
 }
开发者ID:oliverreid,项目名称:Dapper.SimpleLoad,代码行数:35,代码来源:QueryGenerationTests.cs

示例6: autoquery_with_custom_where_mapping_to_single_type_uses_supplied_alias_and_where_condition

        public void autoquery_with_custom_where_mapping_to_single_type_uses_supplied_alias_and_where_condition()
        {
            try
            {
                using (var connection = new SqlConnection())
                {
                    connection
                        .AutoQuery
                        <ProSupportRule>(new [] { "r" },
                        "r.[IsForFirstData] = @isForFirstData",
                        new 
                        {
                            isForFirstData = false,
                            isForGlobalPayments = false,
                            isForValitor = false
                        });
                }
            }
            catch (InvalidOperationException ioe)
            {
                CheckException(ioe);
            }

        }
开发者ID:oliverreid,项目名称:Dapper.SimpleLoad,代码行数:24,代码来源:QueryGenerationTests.cs

示例7: Generates_correct_query_for_count

 public void Generates_correct_query_for_count()
 {
     try
     {
         using (var connection = new SqlConnection())
         {
             connection
                 .AutoQuery
                 <PhoneNumberDto, CountryDto, CurrencyCodeDto>(new
                 {
                     PhoneNumberKey = 1
                 }, 1);
         }
     }
     catch (InvalidOperationException ioe)
     {
         CheckException(ioe);
     }
 }
开发者ID:oliverreid,项目名称:Dapper.SimpleLoad,代码行数:19,代码来源:QueryGenerationTests.cs

示例8: generates_correct_query_using_forward_referencing_foreign_key_attribute

 public void generates_correct_query_using_forward_referencing_foreign_key_attribute()
 {
     try
     {
         using (var connection = new SqlConnection())
         {
             var results = connection.AutoQuery<LocationDto>(
                 new []
                 {
                     typeof(FullAddressDto),
                         typeof(CountyDto),
                         typeof(PostCodeDetailsDto),
                             typeof(PostcodeDto),
                             typeof(PostalDistrictNameDto),
                     typeof(OpportunityDto),
                         typeof(FullAddressDto),
                             typeof(CountyDto),
                             typeof(PostCodeDetailsDto),
                                 typeof(PostalDistrictNameDto),
                                 typeof(PostcodeDto),
                         typeof(ShippingAddressDto),
                             typeof(CountyDto),
                             typeof(PostCodeDetailsDto),
                                 typeof(PostalDistrictNameDto),
                                 typeof(PostcodeDto),
                 },
                 new {LocationGuid = Guid.Empty});
         }
     }
     catch (InvalidOperationException ioe)
     {
         CheckException(ioe);
     }
 }
开发者ID:oliverreid,项目名称:Dapper.SimpleLoad,代码行数:34,代码来源:QueryGenerationTests.cs

示例9: generates_join_using_specified_column_for_many_to_one_with_foreign_key_target_column

 public void generates_join_using_specified_column_for_many_to_one_with_foreign_key_target_column()
 {
     try
     {
         using (var connection = new SqlConnection())
         {
             var results = connection.AutoQuery<SimpleUserWithSipDao, SipAccountMstDao>(
                 new {UserKey = 1}).FirstOrDefault();
         }
     }
     catch (InvalidOperationException ioe)
     {
         CheckException(ioe);
     }
 }
开发者ID:oliverreid,项目名称:Dapper.SimpleLoad,代码行数:15,代码来源:QueryGenerationTests.cs

示例10: generates_correct_query_for_complex_application_dto

 public void generates_correct_query_for_complex_application_dto()
 {
     try
     {
         using (var connection = new SqlConnection())
         {
             var results = connection.AutoQuery<APPLICATION_MST>(
             new[]
             {
                 typeof (LEGAL_INFO_MST),
                 typeof (SALES_CHANNEL_LNK),
                 typeof (LOCATION_MST),
                 typeof (BUSINESS_LEGAL_INFO_LNK),
                 typeof (SHAREHOLDER_MST),
                 typeof (PRINCIPAL_MST),
                 typeof (MERCHANT_MST)
             },
             new
             {
                 ApplicationGuid = Guid.Empty
             }).FirstOrDefault();
         }
     }
     catch (InvalidOperationException ioe)
     {
         CheckException(ioe);
     }
 }
开发者ID:oliverreid,项目名称:Dapper.SimpleLoad,代码行数:28,代码来源:QueryGenerationTests.cs


注:本文中的System.Data.SqlClient.SqlConnection.AutoQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。