עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

הדפסת טבלה ב-entity framework ב-C#

Featured Replies

פורסם

יצרתי פרוייקט entity עם כמה טבלאות בפנים, יצרתי את האובייקט הראשי שמכיל את הכל (entity container name) והכנסתי ידנית נתונים לטבלת ה-students

אני רוצה להדפיס את הטבלה בצורה הבאה כאשר db זה ה-entity container name והוא מכיל כמה טבלאות שאחת מהם מכילה אובייקטים של סטודנט


foreach (Student item in db)
{
Console.WriteLine(item);
}

ב-foreach אחרי ה-db לאיזה מתודה לפנות ? (אני מקבל שגיאת קומפילציה שאומרת foreach statement cannot operate on variables of type 'Students.Model1Container' because 'Students.Model1Container' does not contain a public definition for 'GetEnumerator')

פורסם
  • מחבר

Model1Container

פורסם

אוקי, אז זה אובייקט שאתה יצרת, או שנוצר אוטומטית?

איך יצרת אותו? איזה שדות יש לו?

פורסם
  • מחבר

db זה השם של ה-entity container name שמכיל את כל הטבלאות ובתחילת ה-MAIN פשוט יצרתי אותו כאובייקט.

אני חושב שהייתי צריך לעשות

foreach (Student item in db.Students)

ועכשיו זה מתקמפל אבל בהרצה הוא נופל על MappingExeption שאומר :

Schema specified is not valid. Errors:

Model1.msl(3,4) : error 2062: No mapping specified for instances of the EntitySet and AssociationSet in the EntityContainer Model1Container.

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.