I’ve got an IEnumerable<T> as a parameter of a method, where T is a struct type:
using System;
using System.Collections.Generic;
using System.Linq;
using ...
public static class Foo
{
internal struct CellDiff
{
public int RefX;
public int RefY;
public object OldValue;
public object NewValue;
}
private static void ItemChanged(IEnumerable<CellDiff> diffs, int cellX, int cellY)
{
var change = from CellDiff diff in diffs
where diff.RefX == cellX && diff.RefY == cellY
select diff;
...
}
}
This results in the following error:
(parameter)
IEnumerable<CellDiff> diffsError:
Could not find an implementation of the query pattern for source type ‘CellDiff‘. ‘Where‘ not found.
I’ve also tried doing diffs.AsQueryable(), to no avail.
I usually have no problem doing LINQ queries on IEnumerable<T>. I’m a bit lost as to what’s happening here.
Specifying the type in LINQ query syntax creates a call to the
Castextension method with that type argument.Do you have your own
Castdefined somewhere?