0

I have Job, Tag and TagDto classes. Job class has ICollection<Tag> Tags list. I have query that has all the jobs in it as a IQueryable<Job> list. I have to now select those Jobs that has one or more tags in the Job.Tags list in input.Tags list(which is List<TagDto>) as a new list.

IQueryabke<Job> query;
List<TagDto> input.Tags;

class Job
{
  ICollection<Tag> Tags;
}
class Tag
{
  string Text;
  other properties...
}
class TagDto
{
  string Text;
  other properties...
}

I have tried something like

query = query.Where(p => input.Tags.Any(inputTag => p.Tags.Any(tag => tag.Id == inputTag.Id)));

But I get the error "Unable to create a constant value of type 'ProjectA.Tags.TagDto'. Only primitive types or enumeration types are supported in this context."

sɐunıɔןɐqɐp
  • 3,332
  • 15
  • 36
  • 40
ssjkkp
  • 47
  • 9
  • Check it out https://stackoverflow.com/questions/18929483/unable-to-create-a-constant-value-of-type-only-primitive-types-or-enumeration-ty – Edward N Nov 10 '17 at 13:48
  • Thanks but could you help by elaborating how I can implement that to my current query? I'm pretty new with linq and I can't figure out that long query in your link. – ssjkkp Nov 10 '17 at 14:57

0 Answers0