internal static System.Data.DataTable Fn_LinQToDataTable(System.Data.Linq.DataContext ctx,object query)
{
if (query ==null) {return new DataTable("y");}
//...........
IDbCommand cmd = ctx.GetCommand((IQueryable)(query));
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = (SqlCommand)(cmd);
DataTable dt = new DataTable("sd");
try {cmd.Connection.Open();
adapter.FillSchema(dt, SchemaType.Source);
adapter.Fill(dt); }
catch (Exception ex)
{ MessageBox.Show(ex.Message);
return new DataTable("x"); }
finally {cmd.Connection.Close();}
return dt;
}
Yorumlar
Yorum Gönder