I have problem when copy query linq to same datatable.
DataTable dt_result = filterkontrak.CopyToDataTable();
var query = from q in dt_result.AsEnumerable()
select new
{
ChassisNo = q.Field<string>("ChassisNo"),
Engineno = q.Field<string>("Engineno"),
BuiltYear = q.Field<string>("ManufactureYear"),
VehicleType = q.Field<string>("VehicleType"),
PlatNo = q.Field<string>("LicensePlate"),
Type = q.Field<string>("Type"),
ContractNo = q.Field<string>("Brand"),
ContractDate = q.Field<string>("ContractNo"),
TglGenerate = q.Field<string>("ContractDate"),
FileName = q.Field<string>(FileName),
Status = q.Field<string>("1"),
CreatorID = q.Field<string>(UserId),
LastUserId = q.Field<string>(UserId)
};
DataTable dt_result2 = query.AsEnumerable();
SqlBulkCopy bulkCopy = new SqlBulkCopy(conn.SqlCon());
bulkCopy.DestinationTableName = "TEMP_VMF_LogAssetMngmt";'
Error:
The type 'AnonymousType#1' cannot be used as type parameter 'T' in the generic type or method 'System.Data.DataTableExtensions.CopyToDataTable(System.Collections.Generic.IEnumerable)'.
Couldy anybody improve my code ?