本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}