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).
public static bool SetPhysicianAsNotonServer(DataTable dt)
{
DataTable dtPhysicianServer = dt;
DataTable dtPhysicianClient = GetPhysicianClient();
var query =
from SPhysician in dtPhysicianServer.AsEnumerable()
join CPhysician in dtPhysicianClient.AsEnumerable()
on SPhysician.Field<string>("PhysicianNumber") equals
CPhysician.Field<string>("PhysicianNumber")
select new
{
PhysicianNumber = CPhysician.Field<string>("PhysicianNumber")
};
DataTable FilterDt = query; //query.CopyToDataTable();
//YET TO DO CODE HERE
return true;
}
It exists in a specific namespace are you importing it?
System.Data.DataTableExtensions.CopyToDataTable()
Also confirm the addition of this reference
System.Data.DataSetExtensions
I think that's because your creating a anonymous type to hold the Field
object.
Try this:
var query = from SPhysician in dtPhysicianServer.AsEnumerable()
join CPhysician in dtPhysicianClient.AsEnumerable()
on SPhysician.Field<string>("PhysicianNumber") equals
CPhysician.Field<string>("PhysicianNumber")
select CPhysician;
DataTable FilterDt = query.CopyToDataTable();
Definition of CopyToDataTable<T>
:
public static DataTable CopyToDataTable<T>(
this IEnumerable<T> source
)
where T : DataRow
So what you select with the query must be of type IEnumerable<T>
where T
extends DataRow
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With