Sample I:

I created a public method called LINQToDataTable as following:

public DataTable

}

---------------------------------------------------------------

Example: To use this method, just use the following code sample:

---------------------------------------------------------------

                        select new {country.CountryID,country.CountryName};

DataTable dt = LINQToDataTable(vrCountry);

Sample II

Here is my second method:

public DataTable ToDataTable(System.Data.Linq.DataContext ctx, object query)
{
     if (query == null}

---------------------------------------------------------------

Example: To use this method, just use the following code sample:

---------------------------------------------------------------

                        select new {country.CountryID,country.CountryName};

DataTable dt = LINQToDataTable(objEmpDataContext,vrCountry);

相关文章: