473,508 Members | 2,303 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Casting DataTable to typed when using DataTableExtensions.CopyToDataTable

Hi

I have a LINQ query

var query = from t in TypedDataTable
select t

query contains Typed DataRows but I don't seem to be able to cast the
returned DataTable from the DataTableExtensions.CopyToDataTable:

DataSet.TypedTable tbl = (DataSet.TypedTable)query.CopyToDataTable();

What would be the best approach here?

Thanks
Andrew
Mar 16 '08 #1
2 4626
There is an overload:

TypedTable table = new TypedTable();
query.CopyToDataTable(table, LoadOption.PreserveChanges);

your table should now contain the rows you want.

I haven't tested it (I'm not really a DataTable person...) but give it
a go ;-p

You could perhaps write a custom extension method, but I'm not sure it
would be worth it - since the table isn't an argument you end up
losing type inference...

Marc
Mar 16 '08 #2
Hi Linda

I was surprised that the CopyToDataTable method doesn't support Typed
DataTables but the Merge method does what I need.

Thanks
Andrew
Mar 19 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2851
by: theWizK | last post by:
Hello all. I have noticed that when I generate a strongly-typed dataset from an xml schema that the DataTables that are generated have their constructors marked as internal. What this means is...
231
22923
by: Brian Blais | last post by:
Hello, I saw on a couple of recent posts people saying that casting the return value of malloc is bad, like: d=(double *) malloc(50*sizeof(double)); why is this bad? I had always thought...
6
1743
by: Mountain Bikn' Guy | last post by:
When one gets a row from a database (ie, a DataTable), the row contains a typed value in each column. How is this typically implemented behind scenes. I want to build this functionality myself. The...
3
6477
by: Rakesh Rajan | last post by:
Hi, I have a method, which opens a connection, creates an untyped datable, fills it and returns it back. I have defined a typed datatable in my application as well. For some reasons, I have to...
1
2243
by: Ersin Gençtürk | last post by:
I have 2 typed data tables inherited from the same dataset schema One called : table A with an identity column x column x is constrained to be unique. Other one is : table B with an identity...
0
1112
by: Magnus | last post by:
I would like to filter data in a typed datatable, while maintaining strong type references. The typed dataset/datatable is generated using vs2005 xsd.exe tool from a xml schema definition file....
7
13628
by: S. Lorétan | last post by:
Hi guys, Sorry for this stupid question, but I don't know why it isn't working. Here is my (example) code: namespace Test { class A { public string Label1; }
1
1436
by: | last post by:
I'm querying Index Server to return search results, both regular properties and some custom properties I've created. Index Server has this preference for thinking about information as strings...
15
13480
by: Joseph Geretz | last post by:
I'm a bit puzzled by the current recommendation not to send Datasets or Datatables between application tiers. http://support.microsoft.com/kb/306134 ...
0
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7324
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7382
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5052
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3193
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1556
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.