This following code example is borrowed from MSDN here. I am not getting query.CopyToDataTable() available in my code. (see the commented line in my following code).
Have you referenced System.Data.DataSetExtensions assembly? This extension method is defined there.