tengo este LINQ consulta:¿Por qué no funciona este enunciado LINQ join?
// 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();
que está generando este error:
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] Aquí está el código de WeightedItem
:
public class WeightedItem
{
public int _id;
public decimal? _score;
public WeightedItem(int id, decimal? score)
{
_id = id;
_score = score;
}
}
Puedes ver ¿Qué he hecho mal? El código se compila perfectamente y tanto _ctx.Items como itemScores contienen los valores adecuados.
Puede publicar el código para WeightedItem – Lazarus
Aparentemente WeightedItem no es un tipo primitivo. – DOK
Lazarus, ya está hecho. DOK, lo que significa? – Mickel