Greetings,
I have some code using very old version of LLBLGen (1.0.2005.1 Final) Self-Servicing. Unfortunately, it's not an option for me to upgrade the code base right now because of resource constraints.
We recently had to deal with the primary key changing types on our database from a BIGINT (which was mapped to Int64) to a Int (Mapped to Int32). This change occurred throughout the DB and all FK that linked to this primary key were also updated.
In the designer, I refreshed the model from the new Catalog. The designer properly shows both the types now as Int32 for the PK and for the FKs that related to it.
We regenerated and updated the code to reflect the type changes and everything compiles fine.
However, we now get run time exceptions when we try to access a relation member for the table who's PK changed type from a related table.
The exception SD.LLBLGen.Pro.ORMSupportClasses.ORMValueTypeMismatchException is thrown from SetupSyncClass with the detail shown below.
Additional information: The value 1 is of type 'System.Int64' while the field is of type 'System.Int32'
Here's a partial StackTrace from the generated code.
[External Code]
Data.dll!Abode.Data.EntityClasses.StudentsEntityBase.SetupSyncClass(SD.LLBLGen.Pro.ORMSupportClasses.IEntity relatedEntity) Line 4603 C#
Data.dll!Abode.Data.EntityClasses.StudentsEntityBase.SetRelatedEntity(SD.LLBLGen.Pro.ORMSupportClasses.IEntity relatedEntity, string fieldName) Line 814 C#
[External Code]
Data.dll!Abode.Data.EntityClasses.ClassesEntityBase.SetRelatedEntity(SD.LLBLGen.Pro.ORMSupportClasses.IEntity relatedEntity, string fieldName) Line 278 C#
Data.dll!Abode.Data.EntityClasses.StudentsEntityBase.Class.set(Abode.Data.EntityClasses.ClassesEntity value) Line 7305 C#
Data.dll!Abode.Data.EntityClasses.StudentsEntityBase.GetSingleClass(bool forceFetch) Line 2518 C#
Data.dll!Abode.Data.EntityClasses.StudentsEntityBase.Class.get() Line 7287 C#
Data.dll!Abode.Data.EntityClasses.StudentsEntityBase.ClassName.get() Line 7337 C#
When I step through the Fetch function in the EntityBaseClass (shown below):
try
{
OnFetch();
IDao dao = this.CreateDAOInstance();
base.Fields[(int)ClassesFieldIndex.ClassId].ForcedCurrentValueWrite(classId);
dao.FetchExisting(this, base.Transaction, prefetchPathToUse, contextToUse);
bool fetchResult = false;
if(base.Fields.State == EntityState.Fetched)
{
base.IsNew = false;
fetchResult = true;
if(contextToUse!=null)
{
base.ActiveContext = contextToUse;
IEntity dummy = contextToUse.Get(this);
}
}
return fetchResult;
}
finally
{
OnFetchComplete();
}
The PK (ClassId) is of the correct type until the call to dao.FetchExisting
After this line is executed, a watch on this.ClassId becomes:
'this.ClassId' threw an exception of type 'System.InvalidCastException'
I'm guessing there must be somewhere in the generated code that is not being regenerated and needs to have it's type updated--but I am at a loss to find it. Other tables PKs that started out as Int32's work fine. It's only the tables that changed from Int64's to Int32's that produce the problem.
Unfortunately, this bug is blocking a critical update for us right now, so I appreciate any prompt assistance you can provide.