Ich habe diese LINQ-Abfrage:Warum funktioniert diese LINQ Join-Anweisung nicht?
// types...
LinkedList<WeightedItem> itemScores = new LinkedList<WeightedItem>();
var result = from i in _ctx.Items
join s in itemScores on i.Id equals s._id
orderby s._score descending
select new ItemSearchResult(i, s._score);
// this fails:
return result.ToList();
Welche diesen Fehler generiert:
Unable to create a constant value of type 'System.Collections.Generic.IEnumerable`1'.
Only primitive types ('such as Int32, String, and Guid') are supported in this context.
[EDIT] Hier ist der Code von WeightedItem
:
public class WeightedItem
{
public int _id;
public decimal? _score;
public WeightedItem(int id, decimal? score)
{
_id = id;
_score = score;
}
}
Können Sie sehen, was habe ich falsch gemacht? Der Code kompiliert perfekt und sowohl die _ctx.Items als auch die itemScores enthalten korrekte Werte.
Können Sie den Code für WeightedItem – Lazarus
Anscheinend WeightedItem ist kein primitiver Typ. – DOK
Lazarus, es ist fertig. DOK, was bedeutet? – Mickel