Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
**Case 1**
C#
DataSet oDsParent = new DataSet();
         DataTable odt = new DataTable();
        
         odt.Columns.Add(new DataColumn("DOC_GENO_KEY", typeof(int)));
         odt.Columns.Add(new DataColumn("RESOURCE_TYPE", typeof(string)));
         odt.Columns.Add(new DataColumn("ROUTING_SUB_ID", typeof(int)));
        
         odt.Rows.Add(2, "TEST1", 2);
         odt.Rows.Add(4, "ADMIN", 2);
         odt.Rows.Add(7, "TEST2", 2);
        
         oDsParent.Tables.Add(odt);
         oDsParent.AcceptChanges();
    
        string sTemp =new string ();
         sTemp = "(DOC_GENO_KEY = 4 OR DOC_GENO_KEY = 2) AND (RESOURCE_TYPE = 'TEST1' OR DOC_GENO_KEY = 2 OR ROUTING_SUB_ID = 2)";

 **Case 2**      

     oDsParent = new DataSet();
         odt = new DataTable();
         odt.Columns.Add(new DataColumn("DOCUMENT_ATTACHED", typeof(string)));
         odt.Columns.Add(new DataColumn("ATTACHMENT TYPE", typeof(int)));
        
         odt.Rows.Add("DOC1", 2);
         odt.Rows.Add("DOC2", 1);
         odt.Rows.Add("DOC3", 0);
        
         oDsParent.Tables.Add(odt);
         oDsParent.AcceptChanges();
           
        sTemp = "(DOCUMENT_ATTACHED = 2 OR DOCUMENT_ATTACHED = 1 )";

The dataset oDsParent is formed dynamically
In Case 1 there are 3 columns and their respective data.
In Case 2 there are 2 columns with the data. These columns are filled based on condition in the same dataset(oDsParent) dynamically so that the columns formed are different at each time.

I need to Query the dataset based on the string(sTemp) below which also changes according to the data tables based on the condition.

I cannot use Field <column type="">("Column name") in the query as there are no fixed columns and they change dynamically.

I need a LINQ that can be used generally to filter the dataset no matter which columns are created according to their respective string.

I have created a demo of the dataset and string to understand my issue better.

I used Dataset.Select() method, but because the Query string is too long IIS is crashing and also there are more than 1000 rows in oDsParent.

Posted
Updated 22-Nov-12 18:58pm
v3
Comments
Michiel du Toit 23-Nov-12 21:38pm    
Have you considered using a DataView and filtering the view on sTemp?
shiju87 27-Nov-12 1:16am    
I tried DataView also, but it is of no use.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900