Fran, thank you foy your response. I agree that I don't need to map it, but I have an error --- NHibernate.LazyInitializationException: Initializing[Core.Entities.Topic#1]-failed to lazily initialize a collection of role: Core.Entities.Topic.Votes, no session or session was closed
If I remove the virtual keyword from this readonly property I get an error like this --- The following types may not be used as proxies: Core.Entities.Topic: method get_VotedUpCount should be 'public/ protected virtual' or 'protected internal virtual' On Apr 23, 8:40 pm, Fran Knebels <[email protected]> wrote: > Why map it at all? The point of the mapping is to map domain properties to > table columns. If this is just a convenience method for your domain layer, > you shouldn't have to map it all. > > > > > > > > On Monday, April 23, 2012, s-stude wrote: > > Hi. > > > I'm using Nhibernate 3.2.0.4000 and FluentNHibernate 1.3.0.717. > > > I have next Entity > > > public class Topic : EntityBase > > { > > private readonly ICollection<Vote> _votes; > > > public virtual string Title { get; protected set; } > > public virtual User CreatedBy { get; protected set; } > > public virtual ICollection<Vote> Votes > > { > > get { return _votes; } > > } > > > public virtual int VotedUpCount > > { > > get > > { > > return _votes.Count(v => v.VotedTo == > > VoteType.VoteUp); > > } > > } > > > // .... > > } > > > I need to map VotedUpCount because I get an error. But I don't need > > this column in my table. I just want to get real-world domain entity. > > > I tried this one: > > > public class TopicMap : ClassMap<Topic> > > { > > public TopicMap() > > { > > Id(x => x.Id); > > Map(x => x.Title); > > Map(x => x.VotedUpCount).Access.ReadOnly(); > > Map(x => x.VotedDownCount).Access.ReadOnly(); > > References(x => x.CreatedBy); > > HasMany<Vote>(x => x.Votes) > > .Cascade.All(); > > } > > } > > > But I recieve an error Invalid column name 'VotedUpCount'. > > Is there any way to map it in the proper way? > > > -- > > You received this message because you are subscribed to the Google Groups > > "nhusers" group. > > To post to this group, send email to [email protected]<javascript:;> > > . > > To unsubscribe from this group, send email to > > [email protected] <javascript:;>. > > For more options, visit this group at > >http://groups.google.com/group/nhusers?hl=en. -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
