Moving from LINQpad to the right Visual Studio project?

I am learning LINQ to SQL on LINQpad, and it was great, but there is a lot of magic going on under the hood, which I don't quite understand. I connect to an Oracle database using an optional IQ driver, which can be downloaded inside LINQpad. My query is working for me, and now I need to move it to a new project in Visual Studio.

  • Can I use IQ in my solution in Visual Studio? I can not find any information about using it outside of LINQpad. I tried using the DbLinq DbMetal tool to create the correct connection class, but something in my schema clogs the tool in such a way that it is not for IQ.

  • Can the generated code for LINQpad be exported somehow? Generated Connection Code Oracle works fine in LINQpad - is there a way to reuse the generated code?

+6
source share
3 answers

Yes, it is technically possible to use a typed DataContext that LINQPad creates in your own VS solution. You can retrieve it by running this query:

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

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

Another problem is that it is not possible to configure a typed DataContext, and this may be limiting in the context of writing a VS solution (LINQPad generates a typed DC through Reflection.Emit and therefore there is no source code to configure).

If you want to access Oracle databases through LINQ in a VS project, the best option would be to buy a professional version of DevArt dotConnect for Oracle , which gives you a whole stack, including a built-in VS constructor for writing DataContexts (so you don't need IQ). The whole experience is very similar to LINQ to SQL, but for Oracle (in fact, they imitated the API as much as possible, which eliminates the learning curve). The DevArt LINQ translation engine has improved over the years and is now close to IQ in the translation ability (and at best).

+2
source

Yes, you can use IQ (IQToolkit and IQToolkit-Oracle Provider) in your projects. You can get the DLL from your LINQPad installation (C: \ ProgramData \ LINQPad \ Drivers \ DataContext \ 4.0 \ IQDriver *).

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

+2
source

As you know, Linq to SQL does not support Oracle natively.

The previous SO poster reads: β€œStarting with beta version 4.35, LINQPad fully supports Oracle, now you can make LINQ to Oracle queries. I believe that it uses the DevArt dotConnect libraries to manage this great feat.” [cm. fooobar.com/questions/389934 / ...

which makes me think that if you want the same functions outside LinqPad you need to get the dev art oracle connector

0
source

Source: https://habr.com/ru/post/901539/


All Articles