c# - Dynamic table names -


i have database program query.

it has 3 tables same structure: table1, table2 table3

how can write linq query query each of these table, dynamically specifying tablename?

in addition this. solution must work if additional tables added database. though when writing code table4 did not exist may added.

try this:

      dataset s = new dataset ();       datatable t1 = new datatable ();       t1.columns.add ("a", typeof (int));       t1.columns.add ("b", typeof (string));       s.tables.add (t1);       t1.rows.add (1, "t1");       t1.rows.add (2, "t1");        datatable t2 = new datatable ();       t2.columns.add ("a", typeof (int));       t2.columns.add ("b", typeof (string));       s.tables.add (t2);       t2.rows.add (1, "t2");       t2.rows.add (2, "t2");       t2.rows.add (3, "t2");        var result = t in s.tables.oftype<datatable> ()                    r in t.rows.oftype<datarow> ()                    select r; 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -