I have the following LINQ statement (stationId is int, and version is an array of bytes):
var foundStation = (from wd in _Context.AssignmentWizardDatas from station in wd.AssignmentWizardStationDatas where station.Id == stationId where station.Version.SequenceEqual(version) select station).SingleOrDefault();
When the above code is executed, I encounter the following error:
LINQ to Entities does not recognize the method 'Boolean SequenceEqual [Byte] (System.Collections.Generic.IEnumerable 1[System.Byte], System.Collections.Generic.IEnumerable 1 [System.Byte])', and this method cannot be translated into the storage expression.
After a little reading, I know that the problem is that LINQ cannot convert the call to the SequenceEqual method to the SQL equivalent (I think, anyway). Does anyone know of a workaround for this? Or perhaps I could point me in the right direction when trying to use byte arrays with LINQ queries, I could not find an existing question specifically regarding byte arrays.
Thanks in advance.
EDIT . Using the Jani message, this was the last code used to fix this error:
//eager execution of the linq query to find the stations var foundStation = (from wd in _Context.AssignmentWizardDatas from station in wd.AssignmentWizardStationDatas where station.Id == stationId select station).ToList(); //finding the result in memory var result = (from f in foundStation where f.Version.SequenceEqual(version) select f).SingleOrDefault();
source share