Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to declare variables and use statements in LINQPad?

Tags:

Do you know how to declare variables in LINQPad in order to hold the query result and use it later in multiply queries?

Thanks!

like image 963
Roy Avatar asked Oct 23 '09 06:10

Roy


People also ask

How does LINQPad work?

For each query, LINQPad creates a separate server, which a class that runs in its own process and executes the query in isolation. This isolation prevents queries from interfering with each other (or the UI) and allows LINQPad to safely cancel a query without polluting other application domains.

How can I convert SQL query to LINQ using LINQPad?

Click on "Add connection"; a window will appear. Choose "Default (LINQ to SQL)" and click on the "Next" button. A new window will appear, fill in the required details to get connected with the desired database.

What is LINQPad used for?

LINQPad is a software utility targeted at . NET Framework and . NET Core development. It is used to interactively query SQL databases (among other data sources such as OData or WCF Data Services) using LINQ, as well as interactively writing C# code without the need for an IDE.


1 Answers

Just select C# or VB Statements, and you will be able to write variable declarations.

To view the content of your variables, you can use the Dump extension method available on all types:

var test = "Test String";
test.Dump(); // the content is shown in the output

Or you can use the Console.Write method.

linqpad

If you want to include method or class declarations within a LinqPad file, select C# or VB Program.

like image 153
Christian C. Salvadó Avatar answered Oct 02 '22 23:10

Christian C. Salvadó