Thank you for the shot - you are right! In testing database the values are in upper case, not so in local database and production database. I don't know why this happens in the past (was before my time) and why nHibernate didn't had problems in earlier version.
Anyway I think an update in my testing database will fix my problem now - so again thank you. Am Montag, 1. Oktober 2018 18:29:20 UTC+2 schrieb fknebels: > > Just a shot in the dark, but your error says OK, while your enum is Ok. > > I don't see any code where you are ensuring that where the Enum.Parse is > setting the ignoreCase flag correctly. > > > On Mon, Oct 1, 2018, 12:16 PM Art One <[email protected] <javascript:>> > wrote: > >> Hello, >> >> I'm actually upgrading an older Project with nHibernate 5.1. >> In this project GenericEnumMapper is used to map values (Ok, >> RegistrationPossible, RegistrationInProcess) >> >> Code looks like: >> >> http://orand.blogspot.com/2006/12/generic-nhibernate-enum-string-mapping.html >> >> Everything works great when doing local in Visual Studio but not after >> publishing on server - on server we get: >> >> Stack Trace: >> [ArgumentException: Requested value 'OK' was not found.] >> System.Enum.TryParseEnum(Type enumType, String value, Boolean >> ignoreCase, EnumResult& parseResult) +1185 >> System.Enum.Parse(Type enumType, String value, Boolean ignoreCase) +110 >> NHibernate.Type.EnumStringType.GetInstance(Object code) +67 >> >> [HibernateException: Can't Parse OK as ConServiceStatus] >> NHibernate.Type.EnumStringType.GetInstance(Object code) +210 >> >> >> >> After comparing all settings and configs the last 2 days, I don't know >> where to go now. >> >> So thanks in advance for any hint >> >> >> >> --------------------------------------------------------------------------- >> >> Existing Code (modified): >> public class GenericEnumMapper<TEnum> : EnumStringType >> { >> /// <summary> >> /// Initializes a new instance of the GenericEnumMapper class. >> /// </summary> >> public GenericEnumMapper() >> : base(typeof(TEnum)) >> { >> } >> } >> >> <?xml version="1.0" encoding="utf-8" ?> >> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> >> <class name="Dao.Model.ConService, Dao" table="ConService"> >> <id name="Id" column="Id"> >> <generator class="native" /> >> </id> >> ... >> <property name="LockDateTime" column="LockDateTime" /> >> <property name="LockType" column="LockType" /> >> <property name="Status" column="Status" >> type="Dao.GenericEnumMapper`1[[Dao.Model.ConServiceStatus, Dao]], Dao" >> not-null="true" /> >> >> </class> >> </hibernate-mapping> >> >> >> >> namespace Dao.Model >> { >> using System; >> >> public enum ConServiceStatus >> { >> RegistrationPossible, >> RegistrationInProcess, >> Ok >> } >> >> public class ConService >> { >> private int _id; >> .... >> private DateTime? _lockDateTime; >> private string _lockType; >> private PatientServiceStatus _status; >> >> public virtual DateTime? LockDateTime >> { >> get { return this._lockDateTime; } >> set { this._lockDateTime = value; } >> } >> >> public virtual string LockType >> { >> get { return this._lockType; } >> set { this._lockType = value; } >> } >> >> >> /// <summary> >> /// Status >> /// </summary> >> public virtual ConServiceStatus Status >> { >> get { return this._status; } >> set { this._status = value; } >> } >> } >> } >> >> -- >> You received this message because you are subscribed to the Google Groups >> "nhusers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at https://groups.google.com/group/nhusers. >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/nhusers. For more options, visit https://groups.google.com/d/optout.
