0

I have a requirement to add multiple where conditions with or operator out of which one where condition will have to check if the db column has any of the item in a list provided. Please consider the query below

var res= from table1 in context.table1
         join table2 in context.table2
         on table1.id equals table2.id
         where table1.name=="res1" || table1.description=="desc"
         || table1.name.any(res=>FreeText.Contains(res))
         select table1

this query is leading the compiler to run query multiple times and I am not getting required result. My end goal is to achieve the following sql query

select * from table1 join table2 on table1.id ==table2.id 
  where table1.name=="res1" || table1.description=="desc" || table1.name like "%item1%" ||table1.name like "%item2% ......"

the like statements should be dynamically added based on the items in the list.

Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120

1 Answers1

-1

try this...

var res= from table1 in context.table1
         join table2 in context.table2
         on table1.id equals table2.id
         where table1.name=="res1" || table1.description=="desc"
         || FreeText.Any(p => table1.name.Contains(p, StringComparison.InvariantCultureIgnoreCase))
         select table1
Sria Pathre
  • 182
  • 1
  • 10