Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

How to use Clause "IN"

$
0
0

Hi All,

How can I passed array companies id into the .Where highlight orange query below:-

var companies = companies.Where(c=>!c.Id.Equals(0)).Select(c => c.Id).Distinct().ToList();             RequestEntityDataSource.Where = $"it.Company.Id IN (String.Join(",",{companies} ))&& " +                                                   $"(it.Status = {(int)Status.Saved} || it.status = {(int)Status.Ordered}) && " +                                                  "(it.Id = @IdFilter || @IdFilter = -1) &&" +                                                  "(it.CreatedBy LIKE '%' + @createdByFilter + '%' || @createdByFilter is null) &&" +                                                  "(it.PtName LIKE '%' + @pNameFilter + '%' || @PNameFilter is null) &&" +                                                  "(it.EndUser LIKE '%' + @endUserFilter + '%' || @endUserFilter is null) &&" +                                                  "(it.Name LIKE '%' + @NameFilter + '%' || @NameFilter is null)";

Error:

The query syntax is not valid. Near term ',', line 6, column 23.

Please advise.

Thanks

Regards,

Micheale


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>