NHibernate.QueryException: could not resolve property

Original Post marcus's Avatar

marcus

11 Mar, 2010 02:52 PM via web

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.

  1. Support Staff 2 Posted by James Gregory on 12 Mar, 2010 09:32 AM

    James Gregory's Avatar

    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.

    .Mappings(m =>
      m.AutoMappings
        .ExportTo(@"C:\Mappings")
        .Add(AutoMap.AssemblyOf<ContentItem>())
    
  2. 3 Posted by marcus on 12 Mar, 2010 11:15 AM

    marcus's Avatar

    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.

  3. Support Staff 4 Posted by James Gregory on 17 Mar, 2010 01:34 PM

    James Gregory's Avatar

    I've looked over your files and everything seems fine.

    • What's the type of _repository? What's the generic argument for it?
    • What's the actual property the exception refers to?
  4. James Gregory resolved this discussion on 16 May, 2010 05:48 PM.

Comments are currently closed for this discussion. You can start a new one.

Recent Discussions

05 Jul, 2010 10:29 PM
05 Jul, 2010 12:45 PM
05 Jul, 2010 12:42 PM
05 Jul, 2010 12:17 PM
05 Jul, 2010 12:12 PM

 

03 Jul, 2010 12:26 AM
02 Jul, 2010 02:17 PM
02 Jul, 2010 08:18 AM
02 Jul, 2010 12:20 AM
01 Jul, 2010 10:14 PM