Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi All,

In general we will give TResult type to ExecuteQuery command for our query. But in this scene, I want a query to be executed and I don't know what columns it returns. So, I don't want to give TResult type. Like this...

XML
var varRes = db.ExecuteQuery<SampleMaster>(@TxtQry.Text, objects).ToList();
                if (varRes == null)
                    lblErr.Text = "Information : No Records Found with given search criteria..!";

                gv_Account.DataSource = varRes;
                gv_Account.DataBind();


Here I don't want to give SampleMaster. I don't know what select query is present in TxtQry textbox.
My problem is dynamically, it should return query result in a datatable / toList() is okay with me to assign datasource to gridview.

Thanks in advance....
Posted

1 solution

You can use a class type object to return select query in place of SampleMaster(if samplemastr is a table).

C#
var varRes = db.ExecuteQuery<classname>(@TxtQry.Text, objects).ToList();               
 if (varRes == null)                  
  lblErr.Text = "Information : No Records Found with given search criteria..!";               
  gv_Account.DataSource = varRes;    
  gv_Account.DataBind();</classname>



class declaration

public class className
{
//define here variables as re requirements;
}
 
Share this answer
 
v3

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