Saturday, March 23

How to retrieve data using linq query in DataTable

                     Here I have explained How to retrieve data using linq query stored in DataTable in
In this Article I will explain how to store data into datatable using linq query in have used here data context class and by creating the object of that class we can get the tables present inside that object.

To store the data into datatable follow the below steps.
ShibashishDataClassesDataContext dc = new ShibashishDataClassesDataContext();
var x = from n in dc.Table1 select n;
IDbCommand cmd = dc.GetCommand(x);
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = (SqlCommand)cmd;
DataTable dt = new DataTable();
adapter.FillSchema(dt, SchemaType.Source);

Like this you can store your data into datatable.If you want to learn more about linq query then go to this links,,,,,

Keep coding...

Thanks Shibashish Mohanty

No comments:

Post a Comment

Please don't spam, spam comments is not allowed here.

shibashish mohanty