473,569 Members | 2,880 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Casting DataTable to typed when using DataTableExtens ions.CopyToData Table

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 DataTableExtens ions.CopyToData Table:

DataSet.TypedTa ble tbl = (DataSet.TypedT able)query.Copy ToDataTable();

What would be the best approach here?

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

TypedTable table = new TypedTable();
query.CopyToDat aTable(table, LoadOption.Pres erveChanges);

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
2860
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 when I try to instantiate one of the strongly-typed tables from this dataset from a different assembly, I cannot. Let me provide examples... If...
231
22997
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 (perhaps mistakenly) that the purpose of a void pointer was to cast into a legitimate date type. Is this wrong? Why, and what is considered to be...
6
1749
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 reason I want to do this is because I need an in-memory table without any of the overhead of a DataSet or DataTable. Thanks!
3
6485
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 call the above mentioned method to get data. Unfortunately, as it returns an untyped datatable, I can't assign my typed datatable variable this value...
1
2249
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 column x There are some rows in table A and table B. When I want to add a row from table A to table B I use the function ...
0
1113
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. I don't understand how this is possible when its the dataview that is being used to filter. To filter I have to get the "defaultview" from the...
7
13643
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
1438
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 rather than datatypes.If you really work at it, you can configure Index Server to treat the data as, say, sortable DateTime datatypes, or integer...
15
13491
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 http://msdn2.microsoft.com/en-us/library/ms996381.aspx Formerly, with classic Microsoft DNA architecture, the ADO Recordset was a primary transport medium, recommended for transmitting data...
0
7619
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7930
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7681
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6290
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5228
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3662
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1229
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.