Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Bugs & Issues> Bug in InheritanceInfoProvider.CheckIfIsSubTypeOf
 

Pages: 1
Bugs & Issues
Bug in InheritanceInfoProvider.CheckIfIsSubTypeOf
Page:1/1 

  Print all messages in this thread  
Poster Message
hotchill
User



Location:
Stavanger, Norway
Joined on:
22-Jan-2007 12:29:46
Posted:
156 posts
# Posted on: 03-Jul-2019 12:23:10.  
Hi.

In version 5.5.3 the use of _entityToPathToRoot[typeToCheck] in InheritanceInfoProvider.CheckIfIsSubTypeOf causes a KeyNotFoundException:
Code:
public bool CheckIfIsSubTypeOf(string typeToCheck, string superType)
        {
            if (!_entityToEntityInfo.ContainsKey(superType))
            {
                return false;
            }
            return _entityToPathToRoot[typeToCheck].Contains(superType);
        }


Should it be like this?
Code:
public bool CheckIfIsSubTypeOf(string typeToCheck, string superType) {
            if (!_entityToEntityInfo.ContainsKey(superType)) {
                return false;
            }
            return _entityToPathToRoot.TryGetValue(typeToCheck, out var superTypes) && superTypes.Contains(superType);
        }
Tore Olav Kristiansen
Lead Developer, IdentityStream
 
Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37645 posts
# Posted on: 04-Jul-2019 09:48:09.  
The code is indeed not that solid, as it assumes currently that typeToCheck is an entity type (so the entry is always there). So I assume you ran into this when you passed a type that's not an entity type? (which is a legitimate call, it indeed shouldn't crash on that)

We'll add a change so it's more reliably Regular Smiley


Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
hotchill
User



Location:
Stavanger, Norway
Joined on:
22-Jan-2007 12:29:46
Posted:
156 posts
# Posted on: 04-Jul-2019 10:15:49.  
Thanks Regular Smiley

We are using the IEntity2 CheckIfIsSubTypeOf which takes an integer.

I added two extensions methods to get around the issue. I am calling the top one when I get the exception.
        
Code:
public static bool CheckIfIsSubTypeOf(this IEntity2 entity, IEntityCollection2 entityCollection) {
            return entity.CheckIfIsSubTypeOf(entityCollection.EntityFactoryToUse.ForEntityName);
        }

        public static bool CheckIfIsSubTypeOf(this IEntity2 entity, string entityName) {
            try {
                return entity.CheckIfIsSubTypeOf((int)Enum.Parse(typeof(EntityType), entityName));
            } catch (KeyNotFoundException) {
                return false;
            }
        }
Tore Olav Kristiansen
Lead Developer, IdentityStream
 
Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37645 posts
# Posted on: 05-Jul-2019 10:46:55.  
The fix for this is now available in the 5.4.7 and 5.5.4 hotfix builds.

Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
hotchill
User



Location:
Stavanger, Norway
Joined on:
22-Jan-2007 12:29:46
Posted:
156 posts
# Posted on: 05-Jul-2019 14:46:01.  
Thank you, but the new implementation gives null pointer exception. You are using default(TValue) which give null for List<string>. So it makes sense.

Also we should be passing a valid entity name here because we are going via the EntityType enum.
Tore Olav Kristiansen
Lead Developer, IdentityStream
 
Top
hotchill
User



Location:
Stavanger, Norway
Joined on:
22-Jan-2007 12:29:46
Posted:
156 posts
# Posted on: 05-Jul-2019 15:01:27.  
We have debugged this. The dictionary only contains those entities that are a part of an inheritance hierarchy.

Tore Olav Kristiansen
Lead Developer, IdentityStream
 
Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37645 posts
# Posted on: 06-Jul-2019 10:39:05.  
Ok, yes it's stupid.. Embarrassed Fixing.
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37645 posts
# Posted on: 06-Jul-2019 10:54:57.  
Fixed in new hotfix build, now available. Sorry for this inconvenience.

Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.