Uploaded image for project: 'NHibernate [Moved to GitHub]'
  1. NH-3016

Mapping by code does not properly support nested types

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.2.0.GA
    • Fix Version/s: 3.3.0.CR1
    • Component/s: Mapping by-code
    • Labels:
      None
    • Sprint:

      Description

      Mapping by code does not properly represent the class when using nested types.

      If I have an entity with a nested type as the Id:

      public class Entity
      {
      public class Key
      {
      public virtual Guid Id

      { get; set; }

      public override bool Equals(object obj)
      { if (obj == null) return false; return Id.Equals(((Key)obj).Id); }

      public override int GetHashCode()
      { return Id.GetHashCode(); }
      }

      public virtual Key Id { get; set; }

      public virtual string Name

      { get; set; }

      }

      When I try to map this using code:

      var mapper = new ModelMapper();
      mapper.Class<Entity>(rc => rc.ComponentAsId(entity => entity.Id, cid =>

      { cid.Property(p => p.Id); }

      ));

      I get

      NHibernate.MappingException : Could not compile the mapping document: TestDomain
      ----> NHibernate.MappingException : could not find class: NHibernate.Test.NHSpecificTest.Key, NHibernate.Test
      ----> System.TypeLoadException : Could not load type 'NHibernate.Test.NHSpecificTest.Key' from assembly 'NHibernate.Test, Version=3.2.1.4000, Culture=neutral, PublicKeyToken=null'.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              eamon Eamon Hetherton
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Who's Looking?