Kyabroudi
Kyabroudi

Reputation: 558

LinqDataSource: How to assign IQueryable value to where parameters in code

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

Upvotes: 0

Views: 613

Answers (2)

Brad Rem
Brad Rem

Reputation: 6026

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

Upvotes: 0

priw
priw

Reputation: 51

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;

Upvotes: 1

Related Questions