dbEntities db = new dbEntities();
foreach (ttCategory c in db.ttCategories)
{
var tags=(from t in db.ttproduktes where t.ttCategories.Contains(c) select t.ttTags);
foreach (ttTag t in tags) // here it says:
// Unable to create a constant value - only primitive types
{
t.ToString();
}
}
What am i doing wrong?
In linq-to-entities, you can't use Contains with a class, you can only use it with a primitive type, so you need to change this:
where t.ttCategories.Contains(c)
to
where t.ttCategories.Any(x => x.UniqueProperty == c.UniqueProperty)
var tags = (from t in db.ttproduktes
where t.ttCategories.Any(q => q.Id == c.Id)
select t.ttTags);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With