v 4.0 Adapter. Error on derived entity with no new fields

Posts   
 
    
raist
User
Posts: 114
Joined: 19-Apr-2010
# Posted on: 06-Jun-2013 17:46:37   

v.4.0 6th June release (15th may build). Adapter. Worked OK in v.3.5

BaseProfile is the abstract SuperEntity of a hierarchy. Has 4 fields, one of them is DiscriminatorField.

AdministratorProfile is a derived entity with those 4 fields (no new field) and DiscriminatorField = 1

EntityCollection<BaseProfileEntity> colmyRoles = new EntityCollection<BaseProfileEntity>();

produces the following error in EntityCollection constructor:


System.MissingMethodException: No constructor without parameters for this object
SourceCode error:
Línea 71:   {
Línea 72:       /// <summary>CTor which determines the factory to use from the generic type argument, unless TEntity is an abstract entity. If possible use the ctor which accepts a factory</summary>
Línea 73:       public EntityCollection() : base( (IEntityFactory2)null )
Línea 74:       {
Línea 75:       }
Archivo de origen: D:\tmp\N23_Adapter\DatabaseGeneric\HelperClasses\EntityCollection.cs Línea: 73 

Stack: 
[MissingMethodException: No constructor without parameters for this object.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +98
   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +241
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +69
   System.Activator.CreateInstance(Type type) +6
   SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase2`1.DetermineEntityFactory() in c:\Myprojects\VS.NET Projects\LLBLGen Pro v4.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\AdapterSpecific\EntityCollectionBase2.cs:1478
   SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase2`1..ctor(IEntityFactory2 entityFactoryToUse) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v4.0\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\AdapterSpecific\EntityCollectionBase2.cs:99
   Northwind.HelperClasses.EntityCollection`1..ctor() in D:\tmp\N23_Adapter\DatabaseGeneric\HelperClasses\EntityCollection.cs:73

It is NOT a priority.

TIA

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 06-Jun-2013 19:45:19   

BaseProfile is abstract, which means you can't instantiate from it. The generated class for an abstract entity (marked as such in llblgen pro designer) has an internal constructor, so you can't create new instances of it.

raist
User
Posts: 114
Joined: 19-Apr-2010
# Posted on: 06-Jun-2013 22:17:37   

flushed Once it's not marked as abstract, everything works fine. I should have tried first. Sorry (it used to work that way, and as I was having problems with my calculated fields).

raist
User
Posts: 114
Joined: 19-Apr-2010
# Posted on: 06-Jun-2013 22:52:19   

...but I'm still thinking. It should be abstract (meaning it isn't possible to create a base entity object with IsNew= true). But the use Im trying is only fetching filtered entities (polymorphic), which should be ok. Am I forgetting anything?

Kind regards

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 07-Jun-2013 08:07:40   

Hi Jose,

A side note: v3.5 should raise the same error for that specific code (I tested it myself). Try specifying the factory, as the factory knows how to use/create that 'abstract' entity:

EntityCollection<BaseProfileEntity> colmyRoles = 
     new EntityCollection<BaseProfileEntity>(new BaseProfileEntityFactory());

.. then you should check the type for each result to know what cast to use.

David Elizondo | LLBLGen Support Team