This answer just expands on the comments by Nicknow and myself, so that the question can be marked as answered.
The Dynamics CRM Linq Provider requires the range variable to be the left hand term in the where clause.
Your where clause should be:
where (Guid)SI["sdkmessageprocessingstepid"] == (Guid)S["sdkmessageprocessingstepid"]
instead of:
where (Guid)S["sdkmessageprocessingstepid"] == (Guid)SI["sdkmessageprocessingstepid"]