質問編集履歴
2
誤字訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -162,11 +162,7 @@
|
|
162
162
|
|
163
163
|
私が実行したaspx.csファイルを下記に示します。
|
164
164
|
|
165
|
-
var books = context.Books;のところでcontextを使っているので
|
166
|
-
|
167
|
-
DBにアクセスしていると思っておりましたが勘違いしていますでしょうか。
|
168
|
-
|
169
|
-
尚動作は下記のaspx.csファイルを実行すると正常に文字列が
|
165
|
+
尚動作は下記のaspx.csファイルを実行すると正常に文字列が表示されます。
|
170
166
|
|
171
167
|
|
172
168
|
|
1
aspx.csファイルを追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -155,3 +155,85 @@
|
|
155
155
|
}
|
156
156
|
|
157
157
|
```
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
【追記】
|
162
|
+
|
163
|
+
私が実行したaspx.csファイルを下記に示します。
|
164
|
+
|
165
|
+
var books = context.Books;のところでcontextを使っているので
|
166
|
+
|
167
|
+
DBにアクセスしていると思っておりましたが勘違いしていますでしょうか。
|
168
|
+
|
169
|
+
尚動作は下記のaspx.csファイルを実行すると正常に文字列がひょうじされます。
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
```C#
|
174
|
+
|
175
|
+
using System;
|
176
|
+
|
177
|
+
using System.Collections.Generic;
|
178
|
+
|
179
|
+
using System.Linq;
|
180
|
+
|
181
|
+
using System.Web;
|
182
|
+
|
183
|
+
using System.Web.UI;
|
184
|
+
|
185
|
+
using System.Web.UI.WebControls;
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
namespace WebApplication1
|
190
|
+
|
191
|
+
{
|
192
|
+
|
193
|
+
public partial class WebForm1 : System.Web.UI.Page
|
194
|
+
|
195
|
+
{
|
196
|
+
|
197
|
+
protected void Page_Load(object sender, EventArgs e)
|
198
|
+
|
199
|
+
{
|
200
|
+
|
201
|
+
string bookdata = "";
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
using (var context = new BookModel())
|
206
|
+
|
207
|
+
{
|
208
|
+
|
209
|
+
var books = context.Books;
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
foreach (var book in books)
|
214
|
+
|
215
|
+
{
|
216
|
+
|
217
|
+
bookdata += string.Format("Id:{0}, 図書名{1}, 著者名{2}, 出版社名:{3}, 価格:{4}円<br>",
|
218
|
+
|
219
|
+
book.BookId, book.BookTitle, book.Author.AuthorName, book.Publisher.PublisherName, book.Price);
|
220
|
+
|
221
|
+
}
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
Label1.Text = bookdata;
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
Label1.ForeColor = System.Drawing.Color.Aqua;
|
230
|
+
|
231
|
+
; }
|
232
|
+
|
233
|
+
}
|
234
|
+
|
235
|
+
}
|
236
|
+
|
237
|
+
}
|
238
|
+
|
239
|
+
```
|