Reputation: 28316
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> diffs
Error:
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.
Upvotes: 1
Views: 1288
Reputation: 50114
Specifying the type in LINQ query syntax creates a call to the Cast
extension method with that type argument.
Do you have your own Cast
defined somewhere?
Upvotes: 3
Reputation: 176916
you need to change query like , updated one is like this
var change = from diff in diffs //changed like removed "CellDiff" from this
where diff.RefX == cellX && diff.RefY == cellY
select diff;
thre is no need of CellDiff
after from in you query
Upvotes: 1