Ho questa LINQ-query:Perché questa istruzione di join LINQ non funzionerà?
// 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();
che sta generando questo errore:
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] Ecco il codice di WeightedItem
:
public class WeightedItem
{
public int _id;
public decimal? _score;
public WeightedItem(int id, decimal? score)
{
_id = id;
_score = score;
}
}
Riesci a vedere cosa ho fatto di sbagliato? Il codice viene compilato perfettamente e sia _ctx.Items che itemScores contengono valori corretti.
Puoi pubblicare il codice per WeightedItem – Lazarus
Apparentemente WeightedItem non è un tipo primitivo. – DOK
Lazarus, è fatto. DOK, che significa? – Mickel