Reputation: 181
I am trying to do a like on a table that has a one to many relationship with another. Having some issues with the code for that. Promotion table has a one to many relationship with PromotionMajorChains. I am trying to do a like on the PromotionMajorChains table, on the column MajorChain. The error I am getting: CS1503 Argument 2: cannot convert from 'System.Collections.Generic.IEnumerable' to 'string'
Code:
case MAJOR_CHAIN:
paginatedQueryable = paginatedQueryable.Where(e => EF.Functions.Like(e.Promotion.PromotionMajorChains.Select(mc => mc.MajorChain), $"%{filter.Value}%"));
break;
Example filter.Value = "group"
Upvotes: 0
Views: 51
Reputation: 27416
If you have a set of records, apply predicates which are dedicated for that
paginatedQueryable = paginatedQueryable
.Where(e => e.Promotion.PromotionMajorChains.Any(mc =>
EF.Functions.Like(mc.MajorChain, $"%{filter.Value}%")
);
Upvotes: 1