We have a project running: LLBLGen 5.10.1 - SelfServicing (Two Classes) - SQL Server 2017 - .NET Framework 4.8
In an ASP.NET web application, the following query works fine the first time it runs, however, refreshing the page or navigating to another page that runs that query again returns the error listed below:
var qf = new QueryFactory();
var q = qf.UserSiteRole
.Select(() => UserSiteRoleFields.SiteId.ToValue<Guid>())
.Where(UserSiteRoleFields.UserId == personId)
.CacheResultset(60);
var sites = new TypedListDAO().FetchQuery(q);
The web app is using the MemoryCachedResultsetCache from the LLBLGen Contrib repo for caching.
[InvalidCastException: Specified cast is not valid.]
lambda_method(Closure , ProjectionRow ) +86
SD.LLBLGen.Pro.QuerySpec.DataProjectorToObjectList`1.AddRowToResults(Object[] rawProjectionResult) +51
SD.LLBLGen.Pro.ORMSupportClasses.ProjectionUtils.FetchProjectionFromReader(List`1 valueProjectors, IGeneralDataProjector projector, IDataReader dataSource, Int32 rowsToSkip, Int32 rowsToTake, Boolean clientSideLimitation, Boolean clientSideDistinctFiltering, Boolean clientSidePaging, Boolean performValueProjectionsOnRawRow, Boolean postProcessDBNullValues, Dictionary`2 typeConvertersToRun, IRetrievalQuery queryExecuted) +2034
SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.GetAsProjection(List`1 valueProjectors, IGeneralDataProjector projector, ITransaction transactionToUse, IRetrievalQuery queryToExecute, Boolean performValueProjectionsOnRawRow, Boolean postProcessDBNullValues, Dictionary`2 typeConvertersToRun) +288
SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.GetAsProjection(List`1 valueProjectors, IGeneralDataProjector projector, ITransaction transactionToUse, QueryParameters parameters) +151
SD.LLBLGen.Pro.QuerySpec.SelfServicing.SelfServicingExtensionMethods.FetchQuery(IDao dao, DynamicQuery`1 query, ITransaction transaction) +263
When I remove the .CacheResultset(60) then it works fine. Over, and over again. I had a go at trying to use .WithProjector but I couldn't get it working.
Your help is greatly appreciated.