How to build a queryable to find all words of string array from database column

205 Views Asked by At

I have this code , Any body has a solution

string[] splitSearch = request.Search.Split(' ');// for example: [best , selling , book , of , the , year] or [in , memory , of , love]
var queryable = _context.books.AsQueryable();
queryable = queryable
           .Where(x =>  x.Title.Contains(request.Search)
                     || x.Description.Contains(request.Search)
                  foreach (string split in splitSearch)
                 {
                     ||  x.Title.Contains(split)
                     || x.Description.Contains(split)
                 }
                 );
var Books = await queryable
                    .Skip(request.Offset ?? 0)
                    .Take(request.Limit ?? 3).ToListAsync();

but because foreach is not allowed in where clause its getting an error if i put all queryable in foreach then on Each loop, my query is limited by the added where clause and return false result , I need '||' in where clause and i dont know how many word my client wants to enter

0

There are 0 best solutions below