Linq to Strong Typed Dataset

I need to troubleshoot a LINQ query against a strong typed dataset that is loaded from a SQL database. I'm new to LinqPad. Are there any examples on how to do this?



  • Where is the strongly typed dataset defined? Presumably it's in an assembly that you've created in Visual Studio. Press F4 and add a reference to this assembly.
  • Ok, that's half way there. Now how do I fill the dataset? My existing code uses ADO .net, can I use that here?

    Are there any examples to help me get started? I'm having trouble locating any examples of how to use Linqpad.
  • Filling and querying datasets/datatables in LINQPad is just like in Visual Studio, except that you can Dump the results (instead of having to enumerate through them and call Console.WriteLine), and you don't need to create a solution/project.

    So, start with the same code that you have in VS.
  • In my case the project is website, so the dataset is just a file. When I hit F4 is wants a dll or exe. So do I have to create a new project and copy that dataset into to compile as an EXE/DLL?

    For filling the tables, my current fill routines are in SQL, but I guess it's a good time to convert them to Linq. Would the SQL calls work in Linqpad?

  • LINQPad only lets you reference an exe/dll - you can't reference .cs files.

    So you'll need to find the exe/dll that that you built in VS that includes the typed dataset and reference that. Make sure the typed dataset is marked public (not internal).

    You can use SQL to populate it. Use the same code that you'd do use VS. It's been ages since I've done this, but I seem to remember you use a DataAdapter, and call its Fill method.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!