0

I am trying to assign linq datasource in code behind but I have IQueryable query want to assign in where clouse using Any function like a sub query clause in sql

this is my sql statment

select * from table1 where col1 in (select col1 from table1 where col2 like '%xx%')

how to convert this clouse to bind it into linq datasource code behind

Kyabroudi
  • 549
  • 1
  • 7
  • 22

2 Answers2

1

You can convert this query in linq.

 var result = from c in db.table1
   where db.table1.Any(e => e.col2.Contain("xx"))
   select c;
priw
  • 51
  • 1
  • 5
  • i know how to convert it but linqDataSource.Select accept string parameter i need to pass it into where parameter in code behind i did n't ask to convert sql to linq – Kyabroudi May 25 '13 at 10:05
0

It sounds like you need to call .ToList() on the query that returns IQueryable.

Brad Rem
  • 6,036
  • 2
  • 25
  • 50