[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


LINQ to Typed Dataset problem

Posted on 2009-04-18
Medium Priority
Last Modified: 2013-11-11
In an application I am using an XML file as data storage and I am using it's data through a typed dataset. I tried to execute a very simple LINQ query, like

var recordHd1 = from r in ds.RecordHd select r;

and I got the following error
"Cannot convert lambda expression to type 'string' because it is not a delegate type"

Any good ideas?

Thanks in advance,
Stavros Makridis.
Question by:StuMak
  • 4
  • 3
LVL 12

Expert Comment

ID: 24177803
hmm I assume RecordHd is the data table in your dataset?

I just ran a query test with a dataset i just made here

 DataSet1 ds = new DataSet1();
    var l = from d in ds.Employees
            select d;

and had no errors.
LVL 12

Expert Comment

ID: 24177808
saw 1 other post that had this issue resolved by ensuring these were both declared on the page

using System.Data.Linq;
using System.Linq;

Are you using any of the new Sql Server data types in the datatable? just date, just time, geography, etc?

Author Comment

ID: 24178259
In my original post, I mentioned that I am not using SQL Server at all. The data storage under dataset is an XML file. So I am not using any new SQL datatypes in my datatables. As for the two using lines, I had them both in the file that the code snippet belongs to.

Thanks for your fast response and I would accept gladly any other idea.
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

LVL 64

Expert Comment

by:Fernando Soto
ID: 24178869
Hi StuMak;

Can you post the Strongly typed DataSet class and a sample of the XML file, I would like to run through some test to figure out why you are having the issue.


Author Comment

ID: 24179343
LVL 12

Accepted Solution

wht1986 earned 500 total points
ID: 24181545
StuMak, I created a test VS 2008 c# winform project to test your code.  I did an add existing item and selected your Total dataset file.  I got an initial warning about invaid adapter connection strings but no biggy. Sure enough when I went to write the linq expression it wouldnt compile and I got the same warning message about no delegate that you got. But then I remembered I had created a .net 2.0 project by mistake. I changed it 3.5 but then I still had the same message. I went into "Add Reference" and reselected System.Data.Linq, and the error went away, the cde compiles and runs fine now.  Can you try reselecting thr System.Data.Linq reference and making sure the project build option is .net 3.5.

Author Comment

ID: 24182348
Sure, I will try the same actions that you did and i will let you know.

Author Comment

ID: 24182388
You were right wht1986, the initial project was created for .Net 2.0 and the solution you suggested solved the problem.

Thanks alot.


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month19 days, 13 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question