Unable to create a constant value. Only primitive types

后端 未结 2 1741
误落风尘
误落风尘 2021-02-08 11:35
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);
          


        
2条回答
  •  说谎
    说谎 (楼主)
    2021-02-08 11:58

    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)
    

提交回复
热议问题