Skip to content

Commit 4a1d7f7

Browse files
DavoudEshtehariJRahnamacheenamalhotra
authored
Apply suggestions from code review
Co-authored-by: Javad <[email protected]> Co-authored-by: Cheena Malhotra <[email protected]>
1 parent ee3dbd3 commit 4a1d7f7

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/Common/DbConnectionStringCommon.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -464,19 +464,17 @@ internal static string IPAddressPreferenceToString(SqlConnectionIPAddressPrefere
464464

465465
internal static SqlConnectionIPAddressPreference ConvertToIPAddressPreference(string keyword, object value)
466466
{
467-
if (null == value)
467+
if (value is null)
468468
{
469469
return DbConnectionStringDefaults.IPAddressPreference; // IPv4First
470470
}
471471

472472
string sValue = (value as string);
473-
SqlConnectionIPAddressPreference result;
474-
475-
if (null != sValue)
473+
if (sValue is not null)
476474
{
477475
// try again after remove leading & trailing whitespaces.
478476
sValue = sValue.Trim();
479-
if (TryConvertToIPAddressPreference(sValue, out result))
477+
if (TryConvertToIPAddressPreference(sValue, out SqlConnectionIPAddressPreference result))
480478
{
481479
return result;
482480
}
@@ -489,9 +487,9 @@ internal static SqlConnectionIPAddressPreference ConvertToIPAddressPreference(st
489487
// the value is not string, try other options
490488
SqlConnectionIPAddressPreference eValue;
491489

492-
if (value is SqlConnectionIPAddressPreference)
490+
if (value is SqlConnectionIPAddressPreference preference)
493491
{
494-
eValue = (SqlConnectionIPAddressPreference)value;
492+
eValue = preference;
495493
}
496494
else if (value.GetType().IsEnum)
497495
{

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,7 @@ internal SqlConnectionAttestationProtocol AttestationProtocol
396396
/// </summary>
397397
internal SqlConnectionIPAddressPreference iPAddressPreference
398398
{
399-
get
400-
{
401-
SqlConnectionString opt = (SqlConnectionString)ConnectionOptions;
402-
return opt.IPAddressPreference;
403-
}
399+
get => ((SqlConnectionString)ConnectionOptions).IPAddressPreference;
404400
}
405401

406402
// This method will be called once connection string is set or changed.

0 commit comments

Comments
 (0)