@@ -27,12 +27,12 @@ class SqlInMemoryTableSessionStateRepository : ISqlSessionStateRepository
27
27
#region Sql statement
28
28
// Most of the SQL statements should just work, the following statements are different
29
29
#region CreateSessionTable
30
- private static readonly string CreateSessionTableSql = $ @ "
30
+ private const string CreateSessionTableSql = @"
31
31
IF NOT EXISTS (SELECT *
32
32
FROM INFORMATION_SCHEMA.TABLES
33
- WHERE TABLE_NAME = '{ SqlSessionStateRepositoryUtil . TableName } ')
33
+ WHERE TABLE_NAME = '" + SqlSessionStateRepositoryUtil . TableName + @" ')
34
34
BEGIN
35
- CREATE TABLE { SqlSessionStateRepositoryUtil . TableName } (
35
+ CREATE TABLE " + SqlSessionStateRepositoryUtil . TableName + @" (
36
36
SessionId nvarchar(88) COLLATE Latin1_General_100_BIN2 NOT NULL,
37
37
Created datetime NOT NULL DEFAULT GETUTCDATE(),
38
38
Expires datetime NOT NULL,
@@ -56,7 +56,7 @@ PRIMARY KEY NONCLUSTERED HASH
56
56
#endregion
57
57
58
58
#region GetStateItemExclusive
59
- private static readonly string GetStateItemExclusiveSql = $ @ "
59
+ private const string GetStateItemExclusiveSql = @"
60
60
DECLARE @textptr AS varbinary(max)
61
61
DECLARE @length AS int
62
62
DECLARE @now AS datetime
@@ -69,41 +69,41 @@ DECLARE @LockedCheck bit
69
69
DECLARE @Flags int
70
70
71
71
SELECT @LockedCheck = Locked, @Flags = Flags
72
- FROM { SqlSessionStateRepositoryUtil . TableName }
73
- WHERE SessionID = @ { SqlParameterName . SessionId }
72
+ FROM " + SqlSessionStateRepositoryUtil . TableName + @"
73
+ WHERE SessionID = " + SqlParameterName . SessionId + @"
74
74
IF @Flags&1 <> 0
75
75
BEGIN
76
- SET @actionFlags = 1
77
- UPDATE { SqlSessionStateRepositoryUtil . TableName }
78
- SET Flags = Flags & ~1 WHERE SessionID = @ { SqlParameterName . SessionId }
76
+ SET " + SqlParameterName . ActionFlags + @" = 1
77
+ UPDATE " + SqlSessionStateRepositoryUtil . TableName + @"
78
+ SET Flags = Flags & ~1 WHERE SessionID = " + SqlParameterName . SessionId + @"
79
79
END
80
80
ELSE
81
- SET @ { SqlParameterName . ActionFlags } = 0
81
+ SET " + SqlParameterName . ActionFlags + @" = 0
82
82
83
83
IF @LockedCheck = 1
84
84
BEGIN
85
- UPDATE { SqlSessionStateRepositoryUtil . TableName }
85
+ UPDATE " + SqlSessionStateRepositoryUtil . TableName + @"
86
86
SET Expires = DATEADD(n, Timeout, @now),
87
- @ { SqlParameterName . LockAge } = DATEDIFF(second, LockDate, @now),
88
- @ { SqlParameterName . LockCookie } = LockCookie,
87
+ " + SqlParameterName . LockAge + @" = DATEDIFF(second, LockDate, @now),
88
+ " + SqlParameterName . LockCookie + @" = LockCookie,
89
89
--@textptr = NULL,
90
90
@length = NULL,
91
- @ { SqlParameterName . Locked } = 1
92
- WHERE SessionId = @ { SqlParameterName . SessionId }
91
+ " + SqlParameterName . Locked + @" = 1
92
+ WHERE SessionId = " + SqlParameterName . SessionId + @"
93
93
END
94
94
ELSE
95
95
BEGIN
96
- UPDATE { SqlSessionStateRepositoryUtil . TableName }
96
+ UPDATE " + SqlSessionStateRepositoryUtil . TableName + @"
97
97
SET Expires = DATEADD(n, Timeout, @now),
98
98
LockDate = @now,
99
99
LockDateLocal = @nowlocal,
100
- @ { SqlParameterName . LockAge } = 0,
101
- @ { SqlParameterName . LockCookie } = LockCookie = LockCookie + 1,
100
+ " + SqlParameterName . LockAge + @" = 0,
101
+ " + SqlParameterName . LockCookie + @" = LockCookie = LockCookie + 1,
102
102
@textptr = SessionItemLong,
103
103
@length = 1,
104
- @ { SqlParameterName . Locked } = 0,
104
+ " + SqlParameterName . Locked + @" = 0,
105
105
Locked = 1
106
- WHERE SessionId = @ { SqlParameterName . SessionId }
106
+ WHERE SessionId = " + SqlParameterName . SessionId + @"
107
107
108
108
IF @TextPtr IS NOT NULL
109
109
SELECT @TextPtr
@@ -112,22 +112,22 @@ SELECT @TextPtr
112
112
#endregion
113
113
114
114
#region GetStateItem
115
- private static readonly string GetStateItemSql = $ @ "
115
+ private const string GetStateItemSql = @"
116
116
DECLARE @textptr AS varbinary(max)
117
117
DECLARE @length AS int
118
118
DECLARE @now AS datetime
119
119
SET @now = GETUTCDATE()
120
120
121
- UPDATE { SqlSessionStateRepositoryUtil . TableName }
121
+ UPDATE " + SqlSessionStateRepositoryUtil . TableName + @"
122
122
SET Expires = DATEADD(n, Timeout, @now),
123
- @ { SqlParameterName . Locked } = Locked,
124
- @ { SqlParameterName . LockAge } = DATEDIFF(second, LockDate, @now),
125
- @ { SqlParameterName . LockCookie } = LockCookie,
126
- @textptr = CASE @ { SqlParameterName . Locked }
123
+ " + SqlParameterName . Locked + @" = Locked,
124
+ " + SqlParameterName . LockAge + @" = DATEDIFF(second, LockDate, @now),
125
+ " + SqlParameterName . LockCookie + @" = LockCookie,
126
+ @textptr = CASE " + SqlParameterName . Locked + @"
127
127
WHEN 0 THEN SessionItemLong
128
128
ELSE NULL
129
129
END,
130
- @length = CASE @ { SqlParameterName . Locked }
130
+ @length = CASE " + SqlParameterName . Locked + @"
131
131
WHEN 0 THEN DATALENGTH(SessionItemLong)
132
132
ELSE NULL
133
133
END,
@@ -137,19 +137,19 @@ ELSE NULL
137
137
WHEN (Flags & 1) <> 0 THEN (Flags & ~1)
138
138
ELSE Flags
139
139
END,
140
- @ { SqlParameterName . ActionFlags } = CASE
140
+ " + SqlParameterName . ActionFlags + @" = CASE
141
141
WHEN (Flags & 1) <> 0 THEN 1
142
142
ELSE 0
143
143
END
144
- WHERE SessionId = @ { SqlParameterName . SessionId }
144
+ WHERE SessionId = " + SqlParameterName . SessionId + @"
145
145
IF @length IS NOT NULL BEGIN
146
146
SELECT @textptr
147
147
END
148
148
" ;
149
149
#endregion
150
150
151
151
#region DeleteExpiredSessions
152
- private static readonly string DeleteExpiredSessionsSql = $ @ "
152
+ private const string DeleteExpiredSessionsSql = @"
153
153
SET NOCOUNT ON
154
154
SET DEADLOCK_PRIORITY LOW
155
155
@@ -163,7 +163,7 @@ SessionId nvarchar({SqlSessionStateRepositoryUtil.IdLength}) NOT NULL PRIMARY KE
163
163
164
164
INSERT #tblExpiredSessions (SessionId)
165
165
SELECT SessionId
166
- FROM { SqlSessionStateRepositoryUtil . TableName } WITH (SNAPSHOT)
166
+ FROM " + SqlSessionStateRepositoryUtil . TableName + @" WITH (SNAPSHOT)
167
167
WHERE Expires < @now
168
168
169
169
IF @@ROWCOUNT <> 0
@@ -179,7 +179,7 @@ FETCH NEXT FROM ExpiredSessionCursor INTO @SessionId
179
179
180
180
WHILE @@FETCH_STATUS = 0
181
181
BEGIN
182
- DELETE FROM { SqlSessionStateRepositoryUtil . TableName } WHERE SessionId = @SessionId AND Expires < @now
182
+ DELETE FROM " + SqlSessionStateRepositoryUtil . TableName + @" WHERE SessionId = @SessionId AND Expires < @now
183
183
FETCH NEXT FROM ExpiredSessionCursor INTO @SessionId
184
184
END
185
185
@@ -193,13 +193,13 @@ DEALLOCATE ExpiredSessionCursor
193
193
#endregion
194
194
195
195
#region TempInsertUninitializedItem
196
- private static readonly string TempInsertUninitializedItemSql = $ @ "
196
+ private const string TempInsertUninitializedItemSql = @"
197
197
DECLARE @now AS datetime
198
198
DECLARE @nowLocal AS datetime
199
199
SET @now = GETUTCDATE()
200
200
SET @nowLocal = GETDATE()
201
201
202
- INSERT { SqlSessionStateRepositoryUtil . TableName } (SessionId,
202
+ INSERT " + SqlSessionStateRepositoryUtil . TableName + @" (SessionId,
203
203
SessionItemLong,
204
204
Timeout,
205
205
Expires,
@@ -209,10 +209,10 @@ DECLARE @nowLocal AS datetime
209
209
LockCookie,
210
210
Flags)
211
211
VALUES
212
- (@ { SqlParameterName . SessionId } ,
213
- @ { SqlParameterName . SessionItemLong } ,
214
- @ { SqlParameterName . Timeout } ,
215
- DATEADD(n, @ { SqlParameterName . Timeout } , @now),
212
+ (" + SqlParameterName . SessionId + @" ,
213
+ " + SqlParameterName . SessionItemLong + @" ,
214
+ " + SqlParameterName . Timeout + @" ,
215
+ DATEADD(n, " + SqlParameterName . Timeout + @" , @now),
216
216
0,
217
217
@now,
218
218
@nowLocal,
@@ -221,45 +221,45 @@ DECLARE @nowLocal AS datetime
221
221
#endregion
222
222
223
223
#region ReleaseItemExclusive
224
- private static readonly string ReleaseItemExclusiveSql = $ @ "
225
- UPDATE { SqlSessionStateRepositoryUtil . TableName }
224
+ private const string ReleaseItemExclusiveSql = @"
225
+ UPDATE " + SqlSessionStateRepositoryUtil . TableName + @"
226
226
SET Expires = DATEADD(n, Timeout, GETUTCDATE()),
227
227
Locked = 0
228
- WHERE SessionId = @ { SqlParameterName . SessionId } AND LockCookie = @ { SqlParameterName . LockCookie } " ;
228
+ WHERE SessionId = " + SqlParameterName . SessionId + @" AND LockCookie = " + SqlParameterName . LockCookie ;
229
229
#endregion
230
230
231
231
#region RemoveStateItem
232
- private static readonly string RemoveStateItemSql = $ @ "
233
- DELETE { SqlSessionStateRepositoryUtil . TableName }
234
- WHERE SessionId = @ { SqlParameterName . SessionId } AND LockCookie = @ { SqlParameterName . LockCookie } " ;
232
+ private const string RemoveStateItemSql = @"
233
+ DELETE " + SqlSessionStateRepositoryUtil . TableName + @"
234
+ WHERE SessionId = " + SqlParameterName . SessionId + @" AND LockCookie = " + SqlParameterName . LockCookie ;
235
235
#endregion
236
236
237
237
#region ResetItemTimeout
238
- private static readonly string ResetItemTimeoutSql = $ @ "
239
- UPDATE { SqlSessionStateRepositoryUtil . TableName }
238
+ private const string ResetItemTimeoutSql = @"
239
+ UPDATE " + SqlSessionStateRepositoryUtil . TableName + @"
240
240
SET Expires = DATEADD(n, Timeout, GETUTCDATE())
241
- WHERE SessionId = @ { SqlParameterName . SessionId } " ;
241
+ WHERE SessionId = " + SqlParameterName . SessionId ;
242
242
#endregion
243
243
244
244
#region UpdateStateItemLong
245
- private static readonly string UpdateStateItemLongSql = $ @ "
246
- UPDATE { SqlSessionStateRepositoryUtil . TableName }
247
- SET Expires = DATEADD(n, @ { SqlParameterName . Timeout } , GETUTCDATE()),
248
- SessionItemLong = @ { SqlParameterName . SessionItemLong } ,
249
- Timeout = @ { SqlParameterName . Timeout } ,
245
+ private const string UpdateStateItemLongSql = @"
246
+ UPDATE " + SqlSessionStateRepositoryUtil . TableName + @"
247
+ SET Expires = DATEADD(n, " + SqlParameterName . Timeout + @" , GETUTCDATE()),
248
+ SessionItemLong = " + SqlParameterName . SessionItemLong + @" ,
249
+ Timeout = " + SqlParameterName . Timeout + @" ,
250
250
Locked = 0
251
- WHERE SessionId = @ { SqlParameterName . SessionId } AND LockCookie = @ { SqlParameterName . LockCookie } " ;
251
+ WHERE SessionId = " + SqlParameterName . SessionId + @" AND LockCookie = " + SqlParameterName . LockCookie ;
252
252
#endregion
253
253
254
254
#region InsertStateItemLong
255
- private static readonly string InsertStateItemLongSql = $ @ "
255
+ private const string InsertStateItemLongSql = @"
256
256
DECLARE @now AS datetime
257
257
DECLARE @nowLocal AS datetime
258
258
259
259
SET @now = GETUTCDATE()
260
260
SET @nowLocal = GETDATE()
261
261
262
- INSERT { SqlSessionStateRepositoryUtil . TableName }
262
+ INSERT " + SqlSessionStateRepositoryUtil . TableName + @"
263
263
(SessionId,
264
264
SessionItemLong,
265
265
Timeout,
@@ -269,10 +269,10 @@ DECLARE @nowLocal AS datetime
269
269
LockDateLocal,
270
270
LockCookie)
271
271
VALUES
272
- (@ { SqlParameterName . SessionId } ,
273
- @ { SqlParameterName . SessionItemLong } ,
274
- @ { SqlParameterName . Timeout } ,
275
- DATEADD(n, @ { SqlParameterName . Timeout } , @now),
272
+ (" + SqlParameterName . SessionId + @" ,
273
+ " + SqlParameterName . SessionItemLong + @" ,
274
+ " + SqlParameterName . Timeout + @" ,
275
+ DATEADD(n, " + SqlParameterName . Timeout + @" , @now),
276
276
0,
277
277
@now,
278
278
@nowLocal,
0 commit comments