Book Image

LINQ Quickly

By : N Satheesh Kumar
Book Image

LINQ Quickly

By: N Satheesh Kumar

Overview of this book

<p>This book gets you started with LINQ and shows how it will make your programming life easier by making use of new features from the .NET Framework 3.0. This book is split into seven chapters, each of which is dedicated to presenting a feature of LINQ and its usage in real-life scenarios. <br /><br />Language Integrated Query (LINQ) is a new feature in Visual Studio 2008 that extends its query capabilities, using C# and Visual Basic. Visual Studio 2008 comes with<br />LINQ provider assemblies that enable the use of LINQ with data sources such as in-memory collections, SQL relational databases, ADO.NET Datasets, XML documents, etc.<br />In Visual Studio 2008, Visual C# and Visual Basic are the languages that implement the LINQ language extensions. LINQ language extensions use the new standard query operators API, which is the query language for any collection that implements IEnumerable&lt;T&gt;.</p>
Table of Contents (14 chapters)
LINQ Quickly
Credits
About the Author
About the Reviewer
Preface
Building an ASP.NET Application
LINQ with Outlook

Entity Classes


Entity classes are the objects which represent the database tables. In the previous example, the table collections of the Icrecreams data context, contain three tables for which we need to add the definitions of each table with its columns and its attributes.

System.Data.Linq.Mapping is the namespace that contains the definition for all the attributes. We have to include this in the project to specify the attributes.

The definition of the Categories table would look like this:

[Table(Name = "Categories")]
public class Categories
{
private int categoryID;
private string category;
private string description;
[Column(Name= "CategoryID", IsPrimaryKey=true,
IsDbGenerated=true, DbType="int NOT NULL
IDENTITY",CanBeNull=false)]
public int CategoryID
{
get { return categoryID; }
set { categoryID = value; }
}
[Column(Name="Category", DbType="nvarchar(1000)")]
public string Category
{
get { return category; }
set { category = value; }
}
[Column(Name="Description", DbType="nvarchar(1000...