Sorry, I should have included the exception. My bad. Line 36 in StaticSessionManager is: map.Map (User.Expressions.PasswordHash);
Unable to cast object of type 'System.Reflection.RtFieldInfo' to type 'System.Reflection.PropertyInfo'. at FluentNHibernate.Utils.ReflectionHelper.GetProperty[MODEL] (Expression`1 expression) in d:\Builds\FluentNH\src\FluentNHibernate \Utils\ReflectionHelper.cs:line 33 at FluentNHibernate.AutoMap.AutoMap`1.Map(Expression`1 expression) in d:\Builds\FluentNH\src\FluentNHibernate\AutoMap\AutoMap.cs:line 40 at Procentas.Web.StaticSessionManager.<.cctor>b__2(AutoMap`1 map) in ....\StaticSessionManager.cs:line 36 at FluentNHibernate.AutoMap.AutoPersistenceModel.ForTypesThatDeriveFrom[T] (Action`1 populateMap) in d:\Builds\FluentNH\src\FluentNHibernate \AutoMap\AutoPersistenceModel.cs:line 225 at Procentas.Web.StaticSessionManager.<.cctor>b__1 (MappingConfiguration m) in ....\StaticSessionManager.cs:line 30 at FluentNHibernate.Cfg.FluentConfiguration.Mappings(Action`1 mappings) in d:\Builds\FluentNH\src\FluentNHibernate\Cfg \FluentConfiguration.cs:line 69 at Procentas.Web.StaticSessionManager..cctor() in .... \StaticSessionManager.cs:line 49 /Anders On Mar 3, 2:55 am, Paul Batum <paul.ba...@gmail.com> wrote: > Anders, > > The first approach works, its my preferred solution as I really really hate > magic strings. You never explained what your problem was. Are you getting a > compilation error? runtime error? > > Paul Batum > > On Tue, Mar 3, 2009 at 12:24 AM, Anders <and...@waglund.net> wrote: > > > I resolved this issue by converting my fields to private properties > > and using the Reveal.Property method. > > > private string PasswordHash { get; set; } > > private string _PasswordSalt = Guid.NewGuid().ToString(); > > private string PasswordSalt > > { > > get { return _PasswordSalt; } > > set { _PasswordSalt = value; } > > } > > > AutoPersistenceModel.MapEntitiesFromAssemblyOf<IEntity>() > > .Where(type => type.GetInterface(typeof(IEntity).Name) == typeof > > (IEntity)) > > .ForTypesThatDeriveFrom<User>(map => > > { > > map.Map(Reveal.Property<User>("PasswordHash")); > > map.Map(Reveal.Property<User>("PasswordSalt")); > > })) > > > /Anders > > > On Feb 26, 3:01 pm, Anders <and...@waglund.net> wrote: > > > Hi > > > > I'm trying to use the first option specified athttp:// > > wiki.fluentnhibernate.org/show/StandardMappingPrivateProperties > > > together with auto mapping and ForTypesThatDeriveFrom. > > > > Is this not supported? > > > > Sample code: > > > AutoPersistenceModel.MapEntitiesFromAssemblyOf<IEntity>() > > > .Where(type => type.GetInterface(typeof(IEntity).Name) == > > > typeof(IEntity)) > > > .ForTypesThatDeriveFrom<User>(map => > > > { > > > map.Map(User.Expressions.PasswordHash); > > > map.Map(User.Expressions.PasswordSalt); > > > })) > > > > public class User : IEntity > > > { > > > public virtual int Id { get; set; } > > > > public virtual string UserName { get; set; } > > > > private string _PasswordHash; > > > private string _PasswordSalt = Guid.NewGuid().ToString(); > > > > public virtual void SetPassword(string password) > > > { > > > _PasswordHash = Hasher.Hash(password, > > _PasswordSalt); > > > } > > > > public virtual bool IsPasswordCorrect(string password) > > > { > > > return Hasher.Hash(password, _PasswordSalt) == > > _PasswordHash; > > > } > > > > public static class Expressions > > > { > > > public static readonly > > > System.Linq.Expressions.Expression<Func<User, object>> PasswordHash = > > > x => x._PasswordHash; > > > public static readonly > > > System.Linq.Expressions.Expression<Func<User, object>> PasswordSalt = > > > x => x._PasswordSalt; > > > } > > > } > > > > How are you supposed to do this using fluent nhibernate? > > > > Thanks > > > Anders --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to fluent-nhibernate@googlegroups.com To unsubscribe from this group, send email to fluent-nhibernate+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en -~----------~----~----~----~------~----~------~--~---