Moving From LINQpad to a Proper Visual Studio Project?
Asked Answered
B

3

7

I'm learning LINQ to SQL in LINQpad and it's been great, but there's a lot of magic happening under the hood that I don't quite understand. I am connecting to an Oracle database using the optional IQ driver that can be downloaded inside of LINQpad. I have my query working and now I need to move it into a new project within Visual Studio.

  1. Is it possible to use IQ within my solution in Visual Studio? I can't seem to find any information about using it outside of LINQpad. I've attempted to use DbLinq's DbMetal tool to generate the proper connection class but something in my schema is choking the tool in a way that it did not for IQ.

  2. Can the generated code for LINQpad be exported in some way? The generated Oracle connection code works perfectly in LINQpad - is there a way to just reuse that generated code?

Behoof answered 15/11, 2011 at 17:19 Comment(0)
E
2

Yes, it's technically possible to use the typed DataContext that LINQPad creates within your own VS solution. You can extract it by running a query such as this:

File.Copy (GetType().BaseType.Assembly.Location, ...

As Tom suggests, you'll also need to copy the supporting files in C:\ProgramData\LINQPad\Drivers\DataContext\4.0\IQDriver. Bear in mind that LINQPad uses the DevArt Oracle dotConnect as the ADO.NET backend for Oracle, for which you'll need to buy a commercial license in order to use in your own projects.

Another issue is that there's no way to customize the typed DataContext and this could prove limiting within the context of writing a VS solution (LINQPad generates the typed DC via Reflection.Emit and so there's no source code to tweak).

If you want to access Oracle databases via LINQ in a VS project, a better option might be buy DevArt's professional edition of dotConnect for Oracle which gives you an entire stack including an integrated VS designer for writing DataContexts (so you won't need IQ). The whole experience is very much like LINQ to SQL, but for Oracle (in fact, they've mimicked the API whereever possible which eliminates the learning curve). DevArt's LINQ translation engine has improved over the years and is now close to IQ's in translation ability (and better in some ways).

Eduardo answered 17/11, 2011 at 7:31 Comment(0)
C
2

Yes, you can use the IQ (IQToolkit & IQToolkit-Oracle Provider) within your projects. You can get the dlls from your LINQPad install (C:\ProgramData\LINQPad\Drivers\DataContext\4.0\IQDriver*).

You will also want to use IQToolkit CodeGen tool to create your Entities and mappings.

Chaff answered 16/11, 2011 at 19:14 Comment(0)
E
2

Yes, it's technically possible to use the typed DataContext that LINQPad creates within your own VS solution. You can extract it by running a query such as this:

File.Copy (GetType().BaseType.Assembly.Location, ...

As Tom suggests, you'll also need to copy the supporting files in C:\ProgramData\LINQPad\Drivers\DataContext\4.0\IQDriver. Bear in mind that LINQPad uses the DevArt Oracle dotConnect as the ADO.NET backend for Oracle, for which you'll need to buy a commercial license in order to use in your own projects.

Another issue is that there's no way to customize the typed DataContext and this could prove limiting within the context of writing a VS solution (LINQPad generates the typed DC via Reflection.Emit and so there's no source code to tweak).

If you want to access Oracle databases via LINQ in a VS project, a better option might be buy DevArt's professional edition of dotConnect for Oracle which gives you an entire stack including an integrated VS designer for writing DataContexts (so you won't need IQ). The whole experience is very much like LINQ to SQL, but for Oracle (in fact, they've mimicked the API whereever possible which eliminates the learning curve). DevArt's LINQ translation engine has improved over the years and is now close to IQ's in translation ability (and better in some ways).

Eduardo answered 17/11, 2011 at 7:31 Comment(0)
L
0

As you know, Linq to SQL doesn't support Oracle natively.

A previous SO poster says "As of beta version 4.35, LINQPad supports Oracle fully - you can now do "LINQ to Oracle" queries. I believe it uses the DevArt dotConnect libraries for managing this great feat." [see https://mcmap.net/q/872718/-linqpad-and-oracle/6821073#6821073]

which makes me think that if you want the same functionality outside of LinqPad your going to have to get the dev art oracle connector

Lorislorita answered 16/11, 2011 at 16:20 Comment(2)
LINQPad definitely uses devArt dotConnect for Oracle, but what I can't figure out is if it's required for building the data context. When choosing the driver to download, the description for IQ says "Oracle IQ Provider by WiCKY Hu. ADO.NET providers for MySQL and Oracle by DevArt". Does this mean IQ is built on top of dotConnect?Behoof
IQ lets you plug in your own formatters and providers. LINQPad's IQ package includes an Oracle formatter (written by WiCKY Hu) and an db provider that uses DevArt's ADO.NET classes for Oracle. WiCKY's formatter I seem to remember was written originally to target Oracle's client - I switched it to use DevArts's offering to avoid having to ship Oracle's bloated client.Eduardo

© 2022 - 2024 — McMap. All rights reserved.