עבור לתוכן
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.

MappingException c# NHibernate

Featured Replies

פורסם

היי

יש לי MappingException בעיקבות עבודה על NHibernate

אשמח לעזרה

אני עובד על הקוד הבא


Configuration cfg;
try
{
cfg = new Configuration();
cfg.AddAssembly("NHibernate.Auction");
}
catch (Exception )
{

throw ;
}

אני מקבל

{"Could not add assembly NHibernate.Auction"} System.Exception {NHibernate.MappingException}

לא ברור לי מה אני צריך להכניס כפרמטר ל AddAssembly כדי לגרום ל NHibernate לחפש את הקובץ העל הסיומת hbm.xml

אשר אגב מוגדר כ Embedded Resource

חשבתי שאני צריך להכניס את השם של הקובץ קונפיגורציה שלי אבל זה מחזיר שגיעה דומה

{"Could not add assembly app.config"} System.Exception {NHibernate.MappingException}

קובץ app.config :


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section
name="nhibernate"
type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=*******"
/>
</configSections>

<nhibernate>
<config>
<add
key="connection.driver_class"
value="NHibernate.Driver.MySqlDataDriver" />
<add
key="dialect"
value="NHibernate.Dialect.MySQLDialect" />
<add
key="connection.provider"
value="NHibernate.Connection.DriverConnectionProvider" />
<add
key="connection.connection_string"
value="Database=****;Data Source=*****;User Id=*****;Password=***********" />
</config>

</nhibernate>
</configuration>

קובץ User.hbm.xml


<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="NHibernate.Examples.QuickStart.User, NHibernate.Examples" table="users">
<id name="Id" column="LogonId" type="String" length="20">
<generator class="assigned" />
</id>
<property name="FirstUserName" column="FirstName" type="String" length="40"/>
<property name="LastUserName" column="LastName" type="String" length="40"/>
<property name="Password" type="String" length="20"/>
<property name="PhoneNumber" type="String" length="40"/>
<!--property name="LastLogon" type="DateTime"/-->
</class>
</hibernate-mapping>


אשמח לעזרה

פורסם

אם אתה מתחיל פרוייקט חדש ההמלצה שלי זה לעזוב את כל קבצי ה-hbm האלה ולמפות בעזרת attributes, אפשר להשתמש או ב-NHibernate.Mapping.Attributes (מהאתר הזה http://nhforge.org/media) או ב-Castle Activerecord.

באיזה גרסה של NH אתה משתמש? בעקרון שוחררה כבר גרסה 2 אם כי זה לא מפורסם כמו שצריך באתר שלהם. הקונפיגורציה שאתה הצגת היא ערבוב של חלקים של קבצי קונפיגורציה שמתאימים לגרסאות שונות של NH, חלקן ישנות מאוד.

ככה אמורה להראות קונפיגורציה עדכנית:

<hibernate-configuration>
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.JetDriver.JetDialect, NHibernate.JetDriver</property>
<property name="connection.driver_class">NHibernate.JetDriver.JetDriver, NHibernate.JetDriver</property>
<property name="connection.connection_string">Provider=Microsoft.Jet.OLEDB.4.0;Data Source=effort.mdb</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>

(אצלי זה מותאם לMs access אבל אתה מבין את הרעיון)

תנסה ללכת לפי ההוראות פה: http://nhforge.org/wikis/howtonh/your-first-nhibernate-based-application.aspx

ובכלל כל מה שיש ב-nhforge הוא רפרנס טוב כי האתר כולו חדש והדוגמאות עדכניות.

ארכיון

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

דיונים חדשים

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.