Hi there,
I am working on a TxA- and -B- Series Target programming an application with database connection. So i thought about using a dataset and the "LINQ to Dataset" functionality. So I wrote the following code:
DataSet ds;
...
var result = ds.Tables["tabRecipe"].AsEnumerable()
.Where(row => row.IDRecipe == iIDRecipe && row.Priority >= iStepPriority)
.OrderBy(row => row.Priority)
.FirstOrDefault();
...
But when I'm trying to compile, the following error comes on:
"System.Data.DataTable" has no definition for "AsEnumerable", and there was no extension method "AsEnumerable...
The Microsoft .net documentation about LINQ in the .net cf says that LINQ to Dataset is also working on cf, and also the "AsEnumerable"-Method should be (like you can see here: http://msdn.microsoft.com/de-de/library ... 90%29.aspx)
So why does this piece of code not compile?
Thanks for the help!
LINQ to dataset
-
- Posts: 26
- Joined: Tue Oct 09, 2012 12:56 am
LINQ to dataset
Best regards,
Philip Joebstl
Philip Joebstl
-
- Posts: 824
- Joined: Tue Mar 13, 2012 9:53 am
Re: LINQ to dataset
Only some of the methods are supported in CF and the AsEnumerable is not supported.
http://msdn.microsoft.com/en-us/library ... s.90).aspx
http://msdn.microsoft.com/en-us/library ... s.90).aspx
Best Regards,
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
-
- Posts: 26
- Joined: Tue Oct 09, 2012 12:56 am
Re: LINQ to dataset
Hi Mark,
I somehow didn't notice that these extension methods are not supported in CF.
As always, thank you for the quick answer!
I somehow didn't notice that these extension methods are not supported in CF.
As always, thank you for the quick answer!
Best regards,
Philip Joebstl
Philip Joebstl
-
- Posts: 22
- Joined: Fri May 25, 2012 7:44 am
- Location: Charlotte, NC. USA
Re: LINQ to dataset
According to Microsoft "Version Information" Section they are supported in Compact Framework 3.5, but you must add a reference in your build process to the System.Data.DataSetExtensions.dll. This isn't included in iX Developer projects by default... Have you tried adding the Assembly Reference Manually? You should still only add the single using in your script though...
Then Browse for the Assembly in the Compact Framework SDK Folder.
System.Data will then reference the System.Data.DataSetExtensions.dll and should allow access to the AsEnumerable() member.
When I do this I can build successfully without error, but... I can't confirm it will work on a T7A and T7B (because I have not downloaded it to a real device, only checked that it will build), though you should be able to test that by downloading your resulting project.
Code: Select all
using System.Data;
When I do this I can build successfully without error, but... I can't confirm it will work on a T7A and T7B (because I have not downloaded it to a real device, only checked that it will build), though you should be able to test that by downloading your resulting project.
Best Regards,
Patrick Hall
Patrick Hall