Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 626 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
626
Dung lượng
11,37 MB
Nội dung
this print for content only—size & color not accurate spine = 1.176" 624 page count
Books for professionals By professionals
®
Pro LINQ: LanguageIntegratedQueryinC# 2008
Dear Reader,
Pro LINQ: LanguageIntegratedQueryinC#2008 is all about code. Literally,
this book starts with code and ends with code. In writing this book, it has been
my desire to create a treasury of meaningful LINQ examples. Rather than show
you a single, simplest case example, I’ve strived to fill in the whole picture and
demonstrate the breadth of LINQ operators and prototypes that are available
to you. With this information, you will be able to put LINQ to use as it was
intended and reap the maximum rewards for your investment.
Throughout this book, it is my aim to give you the information that actually
matters in a form that you can use. So, rather than obscure the relevant LINQ
principles by focusing on a complex demonstration application you can’t put to
practical use, ProLINQ cuts right to the chase of each LINQ operator, method,
or class. However, where complexity is necessary to truly demonstrate an issue,
the examples are right there in the thick of it. For example, code samples dem-
onstrating how to handle concurrency conflicts actually create concurrency
conflicts, so you can step through the code and see them unfold.
This book is for anyone with an elementary understanding of C# who wants
to understand LINQ and LINQ-relevant C# 3.0 language features. You need not
be up on all the latest C# 2.0 or 3.0 features to understand Pro LINQ. When a
deeper knowledge of an advanced language feature is necessary, I begin from
the ground up to make sure everyone is well equipped for the discussion.
Joseph C. Rattz, Jr.
US $44.99
Shelve in
Programming/C#
User level:
Intermediate–Advanced
Rattz
LINQ
The eXperT’s Voice
®
in .neT
Pro
LINQ
Language IntegratedQuery
in C# 2008
cyan
MaGenTa
yelloW
Black
panTone 123 c
Joseph C. Rattz, Jr.
Companion
eBook Available
THE APRESS ROADMAP
Silverlight and .NET 3.5
Recipes inC# 2008
Pro C#2008 and the
.NET 3.5 Platform
Pro WPF inC# 2008, 2e
Illustrated C# 2008
Accelerated C# 2008
Pro .NET 3.5 Scalable
Application Design
Expert Service-Oriented
Architecture, 3e
Beginning ASP.NET 3.5
Data Access, 2e
Beginning
C# 2008 Databases
Beginning C# 2008
Pro LINQ: Language
Integrated Query
in C# 2008
www.apress.com
SOURCE CODE ONLINE
Companion eBook
See last page for details
on $10 eBook version
ISBN-13: 978-1-59059-789-7
ISBN-10: 1-59059-789-3
9 781590 597897
5 4 4 9 9
Learn to use the power of Microsoft’s
ground-breaking new technology.
Language Integrated
Query inC# 2008
Pro
netbooks.wordpress.com
Codered @ Updatesofts.com
[...]... can programmatically interact with Listing 1-2 A Simple XML Query Using LINQ to XML using System; using System .Linq; using System.Xml .Linq; XElement books = XElement.Parse( @" Pro LINQ: LanguageIntegratedQueryinC#2008 Joe Rattz Pro WF: Windows Workflow in NET 3.0 Bruce Bukovics Pro C#. .. ■■■ Pro LINQ: LanguageIntegratedQueryinC#2008 Rattz_789-3C01.fm Page 2 Tuesday, October 2, 2007 2:29 PM Rattz_789-3C01.fm Page 3 Tuesday, October 2, 2007 2:29 PM CHAPTER 1 ■■■ Hello LINQ Listing 1-1 Hello LINQ using System; using System .Linq; string[] greetings = {"hello world", "hello LINQ" , "hello Apress"}; var items = from s in greetings where s.EndsWith( "LINQ" ) select s; foreach (var item in. .. My next example shows how to use LINQ to SQL to query database2 tables In Listing 1-3, I query the standard Microsoft Northwind sample database Listing 1-3 A Simple Database Query Using LINQ to SQL using System; using System .Linq; using System.Data .Linq; using nwind; Northwind db = new Northwind(@"Data Source=.\SQLEXPRESS;Initial Catalog=Northwind"); var custs = from c in db.Customers where c.City ==... of LINQ LINQ to SQL LINQ to SQL is the name given to the IQueryable API that allows LINQ queries to work with Microsoft’s SQL Server database This interface was previously known as DLinq in older prereleases of LINQ To take advantage of LINQ to SQL, you must have a reference to the System.Data .Linq. dll assembly in your project and have a using directive such as the following: using System.Data .Linq; ... Obtain LINQ Technically, there is no LINQ product to obtain LINQ is just the project code name for the query feature being added to C# 3.0 and the NET Framework 3.5, which will make their debut in the next version of Visual Studio, Visual Studio 2008 To get up-to-date information on LINQ and Visual Studio 2008, visit http://www.linqdev.com and http://apress.com/book/bookDisplay.html?bID=10241 LINQ. .. piece of XML To take advantage of LINQ to XML, you must have a reference to the System.Xml .Linq. dll assembly in your project and have a using directive such as the following: using System.Xml .Linq; LINQ to DataSet LINQ to DataSet is the name given to the LINQ API for DataSets Many developers have a lot of existing code relying on DataSets Those who do will not be left behind, nor will they need to rewrite... pressing Ctrl+F5 outputs the following data to the console window: Pro LINQ: LanguageIntegratedQueryinC#2008 Did you notice how I parsed the XML data into an object of type XElement? Nowhere did I create an XmlDocument Among the benefits of LINQ to XML are the extensions made to the XML API Now instead of being XmlDocument-centric as the W3C Document Object Model (DOM) XML API requires, LINQ to... create LINQ to Objects queries LINQ to XML LINQ to XML is the name given to the LINQ API dedicated to working with XML This interface was previously known as XLinq in older prereleases of LINQ Not only has Microsoft added the necessary XML libraries to work with LINQ, it has addressed other deficiencies in the standard XML DOM, thereby making it easier than ever to work with XML Gone are the days of having... are getting a sequence of is nwind.Order If the gobbledygook is throwing you, running the example in the debugger and examining the orders variable in the Locals window reveals that the data type of orders is this: System .Linq. IQueryable {System.Data .Linq. DataQuery} This makes it clearer that you have a sequence of nwind.Order Technically, you have an IQueryable... 1 ■ HELLO LINQ Query XML While the example in Listing 1-1 is trivial, the example in Listing 1-2 may begin to indicate the potential power that LINQ puts into the hands of the NET developer It displays the ease with which one can interact with and query Extensible Markup Language (XML) data utilizing the LINQ to XML API You should pay particular attention to how I construct the XML data into an object . Service-Oriented
Architecture, 3e
Beginning ASP.NET 3.5
Data Access, 2e
Beginning
C# 2008 Databases
Beginning C# 2008
Pro LINQ: Language
Integrated Query
in C# 2008
www.apress.com
SOURCE CODE ONLINE
Companion. $44.99
Shelve in
Programming /C#
User level:
Intermediate–Advanced
Rattz
LINQ
The eXperT’s Voice
®
in .neT
Pro
LINQ
Language Integrated Query
in C# 2008
cyan