I'm using LINQPad to create LINQ queries in an application I'm bulding.
I noticed that in the downloaded LINQ in Action samples, e.g. example 4.04, intellisense shows a class "Books" but I don't see any references or "using" statements in the LINQPad tool, here is the sample:
List<Book> books = new List<Book>() { new Book { Title="LINQ in Action" }, new Book { Title="LINQ for Fun" }, new Book { Title="Extreme LINQ" } }; var titles = books .Where(book => book.Title.Contains("Action")) .Select(book => book.Title); titles.Dump();
In "LinqBooks.Common, Business Objects, Book.linq" is where the class seems to be defined:
public class Book { public IEnumerable<Author> Authors {get; set;} public String Isbn {get; set;} public String Notes {get; set;} public Int32 PageCount {get; set;} public Decimal Price {get; set;} public DateTime PublicationDate {get; set;} public Publisher Publisher {get; set;} public IEnumerable<Review> Reviews {get; set;} public Subject Subject {get; set;} public String Summary {get; set;} public String Title {get; set;} public String Test {get; set;} public override String ToString() { return Title; } }
But how does this work so that I can copy in my classes and use LINQPad to quickly build LINQ statements that I can then copy back into my application?
Open up LINQPad and go to File -> New Query or Press Ctrl + N. On Query menu, click Reference and Properties or press F4 to add reference.
LINQPad automatically patches itself by downloading updates into its Application Data folder. It then checks that the new assembly has a valid signature, and if so, forwards to that executable, which then writes itself back to the original file.
LINQPad stores queries in a folder named LINQPad Queries by default, located into the user's Documents folder. All queries saved are displayed beneath a tree view node called My Queries. For the purposes of this book, every query written in LINQPad will be saved in a folder named LINQPad Samples.
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.
If you right click in the code editor in LINQPad and choose Advanced Query Properties, there are two dialogs: Additional References and Additional Namespace Imports.
1) In Additional References, choose Add then click Browse and navigate to your custom assembly.
2) Then, in Additional Namespace Imports, type the namespaces you want to import from that assembly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With