Uploaded image for project: 'iBatis for .NET'
  1. iBatis for .NET
  2. IBATISNET-210

Finding properties on interfaces which "inherites" other interfaces

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • DataAccess 1.9, DataMapper 1.6
    • DataMapper 1.6.1
    • DataMapper
    • None
    • Visual Studio 2005. .NET 2.0, Windows

    Description

      Here is the scenario explained. Don't know if this is really a bug or something that iBatis is just not supposed to support

      First of all lets sketch some simple interfaces and domain classes

      public interface IBaseDomain
      {
      Guid Id

      { get; set; }
      }

      public interface IAddress : IBaseDomain
      {
      string Streetname { get; set; }

      }

      public interface IUser : IBaseDomain
      {
      IAddress Address

      { get; set; }

      }

      public class BaseDomain : IBaseDomain
      {
      public Guid Id
      {
      get

      { ......... }
      set { ......... }

      }

      }

      public class Address : IBaseDomain, IAddress
      {
      public string Streetname
      {
      get

      { ......... }
      set { ......... }

      }
      }

      public class User : IBaseDomain, IUser
      {
      public IAddress Address
      {
      get

      { .......... }
      set { .......... }

      }

      }

      Then in a SqlMap we have some statements etc. and a resultmap based on the 'User' class which uses 'Address.Id' and 'Address.Streetname' in the propertynames.... and then problems start because iBatis can only find 'Streetname' property on IAddress and not property 'Id'. The reason is that 'Id' exists in 'IBaseDomain' interface and not directly in the 'IAddress' interface.

      In IBatisNet.Common.Utilities.Objects.ReflectionInfo and IBatisNet.Common.Utilities.Objects.Members.DelegatePropertyGetAccessor (only two places I got problems but maybe more exists) you will get en exception saying that "Property 'Id' on..... can not be found"

      What I did to get going was to do some minor corrections in the mentioned classes where I check if type is an interface and in that case I don't only check for available properties on the type itself, but also use GetInterfaces() on the type to enumerate "inherited" interfaces and check for the property on these types.

      I have found no sideeffects on these little hacks but I'm also only using a minor part of the framework

      Attachments

        Activity

          People

            gilles Gilles Bayon
            hujensen Henrik Uffe Jensen
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: