c# - How to use EXISTS in DataTable filterExpression? -


i need exists filtering datatable in c#.net have tried

string sortexpression="id asc"; string filterexpression; datatable dt; datarow[] dra; filterexpression = "exists (select distinct id table_b b a.id=b.id )"; dra = dtadvancedsearched.select(filterexpression, sortexpression); dt = dra .copytodatatable(); 

but generate error

please can 1 me use exists in .net

there no exists in in rowfilter syntax.

so suggest use linq-to-dataset instead:

ienumerable<datarow> tablebrows = table_b.asenumerable(); datatable dt = dtadvancedsearched.asenumerable()     .where(row => tablebrows.any(b => b.field<int>("id") == row.field<int>("id")))     .orderby(row => row.field<int>("id"))     .copytodatatable(); 

Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -