问题描述
我使用LINQPad创造我的bulding的应用LINQ查询。
I'm using LINQPad to create LINQ queries in an application I'm bulding.
我注意到,在下载 LINQ在行动 STRONG >样本,如例如4.04,智能感知显示类书籍,但我看不出有任何的引用或是,在LINQPad工具陈述,这里是示例:
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();
在LinqBooks.Common,Business Objects公司, Book.linq 是其中类似乎被定义为:
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;
}
}
但是,如何做到这一点的工作,让我可在我的课复制和使用LINQPad来快速构建LINQ语句,我可以再复制回我的应用程序?
推荐答案
如果你的权利在LINQPad代码编辑器中单击并选择高级查询属性,有两个对话框:其他参考文献和其他命名空间的进口
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)在其他参考下,选择添加,然后点击浏览并浏览到您的自定义程序集。
1) In Additional References, choose Add then click Browse and navigate to your custom assembly.
2 )然后,在其他命名空间的进口,键入命名空间您想从组装进口。
2) Then, in Additional Namespace Imports, type the namespaces you want to import from that assembly.
这篇关于如何LINQPad引用其他类,如书籍在LINQ行动样本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!