I've just changed a column from being nvarchar(32) to binary(20)
And this query now completely fails:-
var existingImage = adapter.FetchFirst(new QueryFactory().Image
.Where(ImageFields.Hash == coverImage.Hash)
.Where(ImageFields.Data.Length().Equal(bytes.Length)));
This is the Exception
SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException
HResult=0x80131600
Message=An exception was caught during the execution of a retrieval query: Failed to convert parameter value from a Byte to a Byte[].. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.
Source=SD.LLBLGen.Pro.ORMSupportClasses
StackTrace:
at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityMaterializerBase.Materialize(Func`4 valueReadErrorHandler, String& failureErrorText)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore.ExecuteMultiRowRetrievalQuery(IRetrievalQuery queryToExecute, IEntityFactory2 entityFactory, IEntityCollection2 collectionToFill, IFieldPersistenceInfo[] fieldsPersistenceInfo, Boolean allowDuplicates, IEntityFields2 fieldsUsedForQuery)
at SmartLibrarian.DAL.DatabaseSpecific.DataAccessAdapter.ExecuteMultiRowRetrievalQuery(IRetrievalQuery queryToExecute, IEntityFactory2 entityFactory, IEntityCollection2 collectionToFill, IFieldPersistenceInfo[] fieldsPersistenceInfo, Boolean allowDuplicates, IEntityFields2 fieldsUsedForQuery) in F:\src\SmartLibrarian\SmartLibrarian.DAL\Custom\DataAccessAdapter.cs:line 586
Inner Exception 1:
InvalidCastException: Failed to convert parameter value from a Byte to a Byte[].
Inner Exception 2:
InvalidCastException: Invalid cast from 'System.Byte' to 'System.Byte[]'.
I'll attach a screenshot of the query is trying to generate but the gist of it is that LLBLGen has tried to create a Parameter for each byte!
But the query should look something like this for SQL Server
SELECT * FROM Image WHERE Hash=0xC33608676DA2787A319312A6CE0B81A3D4CFFC82
Attachments
Filename |
File size |
Added on |
Approval |
1.png
|
24,020 |
25-Apr-2019 15:24.49 |
Approved |