質問編集履歴
1
sql,data
test
CHANGED
File without changes
|
test
CHANGED
@@ -154,6 +154,118 @@
|
|
154
154
|
|
155
155
|
|
156
156
|
|
157
|
+
SqlCommandPairは、
|
158
|
+
|
159
|
+
```
|
160
|
+
|
161
|
+
public SqlCommandPair(string command, params SqlParameter[] args)
|
162
|
+
|
163
|
+
{
|
164
|
+
|
165
|
+
Command = command;
|
166
|
+
|
167
|
+
Parameters = args;
|
168
|
+
|
169
|
+
}
|
170
|
+
|
171
|
+
```
|
172
|
+
|
173
|
+
です。
|
174
|
+
|
175
|
+
DBAccess.Selectは、
|
176
|
+
|
177
|
+
```C#
|
178
|
+
|
179
|
+
public static List<T> Select<T>(SqlCommandPair selectCommand, Func<SqlDataReader, T> getDatumFunc)
|
180
|
+
|
181
|
+
{
|
182
|
+
|
183
|
+
var returnlists = new List<T>();
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
using (var connection = new SqlConnection(Properties.Settings.Default.DBConnectionString))
|
188
|
+
|
189
|
+
{
|
190
|
+
|
191
|
+
try
|
192
|
+
|
193
|
+
{
|
194
|
+
|
195
|
+
using (var sqlCommand = new SqlCommand(selectCommand.Command, connection))
|
196
|
+
|
197
|
+
{
|
198
|
+
|
199
|
+
foreach (var parameter in selectCommand.Parameters)
|
200
|
+
|
201
|
+
{
|
202
|
+
|
203
|
+
sqlCommand.Parameters.Add(parameter);
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
connection.Open();
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
using (var reader = sqlCommand.ExecuteReader())
|
214
|
+
|
215
|
+
{
|
216
|
+
|
217
|
+
try
|
218
|
+
|
219
|
+
{
|
220
|
+
|
221
|
+
// モデルにデータを移す
|
222
|
+
|
223
|
+
while (reader.Read())
|
224
|
+
|
225
|
+
{
|
226
|
+
|
227
|
+
returnlists.Add(getDatumFunc(reader));
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
}
|
232
|
+
|
233
|
+
finally
|
234
|
+
|
235
|
+
{
|
236
|
+
|
237
|
+
reader.Close();
|
238
|
+
|
239
|
+
}
|
240
|
+
|
241
|
+
}
|
242
|
+
|
243
|
+
}
|
244
|
+
|
245
|
+
}
|
246
|
+
|
247
|
+
finally
|
248
|
+
|
249
|
+
{
|
250
|
+
|
251
|
+
connection.Close();
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
}
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
return returnlists;
|
260
|
+
|
261
|
+
}
|
262
|
+
|
263
|
+
```
|
264
|
+
|
265
|
+
でした。
|
266
|
+
|
267
|
+
|
268
|
+
|
157
269
|
|
158
270
|
|
159
271
|
###補足情報(言語/FW/ツール等のバージョンなど)
|