iBatis for .NET
  1. iBatis for .NET
  2. IBATISNET-210

Finding properties on interfaces which "inherites" other interfaces

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: DataAccess 1.9, DataMapper 1.6
    • Fix Version/s: DataMapper 1.6.1
    • Component/s: DataMapper
    • Labels:
      None
    • Environment:
      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

        Activity

        Hide
        Gilles Bayon added a comment -

        As you made some fix, could you share them so that I could incorporate them and check if there's no side effect.
        Thanks

        Show
        Gilles Bayon added a comment - As you made some fix, could you share them so that I could incorporate them and check if there's no side effect. Thanks
        Hide
        Gilles Bayon added a comment -

        In SVN

        Show
        Gilles Bayon added a comment - In SVN

          People

          • Assignee:
            Gilles Bayon
            Reporter:
            Henrik Uffe Jensen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development