Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 82636e0

Browse files
committed
C#7-fy OrmLiteConfig
1 parent 7836f8d commit 82636e0

File tree

1 file changed

+11
-26
lines changed

1 file changed

+11
-26
lines changed

src/ServiceStack.OrmLite/OrmLiteConfig.cs

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,8 @@ public static class OrmLiteConfig
2525

2626
public static int CommandTimeout
2727
{
28-
get
29-
{
30-
return commandTimeout ?? defaultCommandTimeout;
31-
}
32-
set
33-
{
34-
commandTimeout = value;
35-
}
28+
get => commandTimeout ?? defaultCommandTimeout;
29+
set => commandTimeout = value;
3630
}
3731

3832
private static IOrmLiteDialectProvider dialectProvider;
@@ -47,24 +41,19 @@ public static IOrmLiteDialectProvider DialectProvider
4741
}
4842
return dialectProvider;
4943
}
50-
set
51-
{
52-
dialectProvider = value;
53-
}
44+
set => dialectProvider = value;
5445
}
5546

5647
public static IOrmLiteDialectProvider GetDialectProvider(this IDbCommand dbCmd)
5748
{
58-
var ormLiteCmd = dbCmd as OrmLiteCommand;
59-
return ormLiteCmd != null
49+
return dbCmd is OrmLiteCommand ormLiteCmd
6050
? ormLiteCmd.DialectProvider
6151
: DialectProvider;
6252
}
6353

6454
public static IOrmLiteDialectProvider GetDialectProvider(this IDbConnection db)
6555
{
66-
var ormLiteConn = db as OrmLiteConnection;
67-
return ormLiteConn != null
56+
return db is OrmLiteConnection ormLiteConn
6857
? ormLiteConn.DialectProvider
6958
: DialectProvider;
7059
}
@@ -76,25 +65,22 @@ public static IOrmLiteExecFilter GetExecFilter(this IOrmLiteDialectProvider dial
7665
}
7766

7867
public static IOrmLiteExecFilter GetExecFilter(this IDbCommand dbCmd) {
79-
var ormLiteCmd = dbCmd as OrmLiteCommand;
80-
var dialectProvider = ormLiteCmd != null
68+
var dialectProvider = dbCmd is OrmLiteCommand ormLiteCmd
8169
? ormLiteCmd.DialectProvider
8270
: DialectProvider;
8371
return dialectProvider.GetExecFilter();
8472
}
8573

8674
public static IOrmLiteExecFilter GetExecFilter(this IDbConnection db) {
87-
var ormLiteConn = db as OrmLiteConnection;
88-
var dialectProvider = ormLiteConn != null
75+
var dialectProvider = db is OrmLiteConnection ormLiteConn
8976
? ormLiteConn.DialectProvider
9077
: DialectProvider;
9178
return dialectProvider.GetExecFilter();
9279
}
9380

9481
public static void SetLastCommandText(this IDbConnection db, string sql)
9582
{
96-
var ormLiteConn = db as OrmLiteConnection;
97-
if (ormLiteConn != null)
83+
if (db is OrmLiteConnection ormLiteConn)
9884
{
9985
ormLiteConn.LastCommandText = sql;
10086
}
@@ -104,8 +90,7 @@ public static void SetLastCommandText(this IDbConnection db, string sql)
10490

10591
public static void SetCommandTimeout(this IDbConnection db, int? commandTimeout)
10692
{
107-
var ormLiteConn = db as OrmLiteConnection;
108-
if (ormLiteConn == null)
93+
if (!(db is OrmLiteConnection ormLiteConn))
10994
throw new NotImplementedException(string.Format(RequiresOrmLiteConnection,"CommandTimeout"));
11095

11196
ormLiteConn.CommandTimeout = commandTimeout;
@@ -167,7 +152,7 @@ public static IOrmLiteResultsFilter ResultsFilter
167152
var state = OrmLiteContext.OrmLiteState;
168153
return state?.ResultsFilter;
169154
}
170-
set { OrmLiteContext.GetOrCreateState().ResultsFilter = value; }
155+
set => OrmLiteContext.GetOrCreateState().ResultsFilter = value;
171156
}
172157

173158
private static IOrmLiteExecFilter execFilter;
@@ -182,7 +167,7 @@ public static IOrmLiteExecFilter ExecFilter
182167
? dialectProvider.ExecFilter ?? execFilter
183168
: execFilter;
184169
}
185-
set { execFilter = value; }
170+
set => execFilter = value;
186171
}
187172

188173
public static Action<IDbCommand, object> InsertFilter { get; set; }

0 commit comments

Comments
 (0)