Cast Exception

Posts   
 
    
NewMind
User
Posts: 9
Joined: 27-Aug-2012
# Posted on: 04-Sep-2012 23:07:21   

I just upgraded from 1.0 to 3.5.

I finally seem to have things up and running. I am running into an odd exception that I am having a hard time tracking down:


Unable to cast object of type 'System.DateTime' to type 'System.String'.

[InvalidCastException: Unable to cast object of type 'System.DateTime' to type 'System.String'.]

SD.LLBLGen.Pro.ORMSupportClasses.PersistenceCore.ReadRowIntoFields(Object[] values, IEntityFieldsCore rowDestination, List1 fieldIndexToOrdinal, IFieldPersistenceInfo[] fieldsPersistenceInfo, UniqueList1 stringCacheForFetcher) +308 SD.LLBLGen.Pro.ORMSupportClasses.PersistenceCore.CreateEntityInstanceFromReaderRow(IEntityFactoryCore entityFactory, Int32 numberOfFieldsInQuery, IFieldPersistenceInfo[] fieldsPersistenceInfo, InheritanceHierarchyType typeOfHierarchy, Dictionary2 hierarchyFieldAliasesToOrdinals, List1 fieldIndexToOrdinal, Dictionary2 entityFieldStartIndexesPerEntity, Boolean hasExcludedFields, IFieldPersistenceInfo[] persistenceInfosForRowReader, Object[] valuesOfRow, UniqueList1 stringCacheForFetcher, IEntityFactoryCore& entityFactoryToUse) +104 SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.ExecuteMultiRowRetrievalQuery(IRetrievalQuery queryToExecute, ITransaction containingTransaction, IEntityCollection collectionToFill, Boolean allowDuplicates, IEntityFields fieldsUsedForQuery, IFieldPersistenceInfo[] fieldPersistenceInfos) +556 SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PerformGetMultiAction(ITransaction containingTransaction, IEntityCollection collectionToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPredicate selectFilter, IRelationCollection relations, IPrefetchPath prefetchPathToUse, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize) +520 SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.GetMulti(ITransaction containingTransaction, IEntityCollection collectionToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IEntityFactory entityFactoryToUse, IPredicate selectFilter, IRelationCollection relations, IPrefetchPath prefetchPathToUse, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize) +54 SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase`1.GetMulti(IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relations, IPrefetchPath prefetchPathToUse, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize) +114

SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase`1.GetMulti(IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses) +26

I verified that my field datatypes match my table(I did not change what the refresh brought down) in the designer. Any suggestions where to look next?

Thanks Daniel

NewMind
User
Posts: 9
Joined: 27-Aug-2012
# Posted on: 04-Sep-2012 23:11:58   

Sorry forgot to add...this is when I call GetMulti()

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 05-Sep-2012 08:18:40   
  • When you upgrade to v3.5, Did you re-generate the code ater upgrade the project?
  • Are you using the lastest v3.5 runtime libraries?
  • Please show the exact code that triggers the exception.
David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39910
Joined: 17-Aug-2003
# Posted on: 05-Sep-2012 09:29:31   

Also enable tracing (see 'troubleshooting and debugging') and check the query being generated.

Frans Bouma | Lead developer LLBLGen Pro
NewMind
User
Posts: 9
Joined: 27-Aug-2012
# Posted on: 05-Sep-2012 18:29:30   

Hi Otis,

Thanks! that did the trick!

After enabling tracing I was able to see the query being executed.

It turns out my view was corrupt and was returning data in incorrect columns. I drop and recreated the view and the app is working!

I checked production and the view has the same issue. I am assuming this was a non breaking scenario in version 1.0?

Thanks again for the quick response and tips that removed my roadblock

Best Daniel