NHibernate.QueryException: could not resolve property
I'm using the automapping feature in fnh and the mappings looks like this:
var cfg = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ShowSql()
.ConnectionString(c => c.FromConnectionStringWithKey("dbConn")))
.Mappings(m => m.AutoMappings.Add(AutoMap.AssemblyOf<ContentItem>()
.Where(t => t.IsSubclassOf(typeof(ContentItem)))
.IncludeBase<ContentItem>()
.Override<ContentItem>(map => map.Id(x => x.Id).GeneratedBy.Identity())
.Setup(s => {
s.IsDiscriminated = type => true;
s.DiscriminatorColumn = type => "type";
s.SubclassStrategy = type => SubclassStrategy.Subclass;
})
In my repository I have this method
public T Get(Expression<Func<T, bool>> predicate) {
return (T) Session.CreateCriteria(typeof (T)).Add(predicate).UniqueResult();
}
and i use it from my code like this
public ActionResult Index(string pagePath) {
var model = _repository.Get(x => x.UrlSegment == pagePath);
return View(new BlogModel(model));
}
and when I call this method I get an NHibernate.QueryException: could not resolve property.
Please see the attached file for complete stacktrace.
- stacktrace.txt 3.4 KB
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by James Gregory on 12 Mar, 2010 09:32 AM
Could you post your entities? Specifically the one containing
UrlSegment
.Also, if you replace your
AutoMappings
call with the following, it'll export the XML mappings that are generated; if you could attach those too it'll help us debug.3 Posted by marcus on 12 Mar, 2010 11:15 AM
Here is the files you asked for, my mappings for all my entities and my ContentItem.
I can say that I downloaded the latest buid from your site a couple of days ago and all sudden it seems like something has happend to the automapping feature in fnh because I need to override all my properties and add the mapping manually.
Support Staff 4 Posted by James Gregory on 17 Mar, 2010 01:34 PM
I've looked over your files and everything seems fine.
_repository
? What's the generic argument for it?James Gregory resolved this discussion on 16 May, 2010 05:48 PM.