Architecture of LINQ

January 17th, 2008 | Posted by Vidya Vrat in LINQ - (0 Comments)

LINQ consists of three major components:

*LINQ to Objects
*LINQ to ADO.NET, which includes
*LINQ to SQL (formerly called DLinq)
*LINQ to DataSet (formerly called LINQ over DataSet)
*LINQ to Entities
*LINQ to XML (formerly called XLinq)

The folloing figure depicts the LINQ architecture which clearly shows the various components of LINQ and their related data stores.

LINQ to Objects deals with in-memory data. Any class that implements the IEnumerable interface (in the System.Collections.Generic namespace) can be queried with Standard Query Operators.

LINQ to ADO.NET (also known as LINQ enabled ADO .NET) deals data from external sources, basically anything ADO.NET can connect to. Any class that implements IEnumerableor IQueryable (in the System.Query namespace) can be queried with Standard Query Operators. The LINQ to ADO.NET functionality could be achieved by using System.Data.Linq namespace.

LINQ to XML is a comprehensive API for in-memory XML programming. Like the rest of LINQ, it includes Standard Query Operators, and it can also be used in concert with LINQ to ADO.NET, but its primary purpose is to unify and simplify the kinds of things that disparate XML tools, like XQuery, XPath and XSLT are typically used to do. The LINQ to XML functionality could be achieved by using System.Xml.Linq namespace.

I have just got my C# 2008 Databases book which I have been authoring for Apress Inc. USA got released on 14-Jan-2008. Here are the details which may interest you. This book mainly covers SQL Server 2005 new T-SQL features,Visual Studio 2008, LINQ, ADO.NET 3.5 besides all other concepts you need to know. Do have look at the Table of Contents below.

To purchase this book please follow your desired links you would like to purchase it from Apress Inc or Amazon

I believe that this book will become availabe in INDIA by the later half of this year 2008.So if you don’t want to purcase it online and would like to have it in INDIA, then please feel free to contact me at my e-mail Vidya_mct@yahoo.com

Who This Book Is For
If you are an application developer who likes to interact with databases using C# this book is for you, as it covers programming SQL Server 2005 using C# 2008. This book does not require or even assume that you have sound knowledge of C# 2.0 and SQL Server 2000 and database concepts. We have covered all the fundamentals that other books assume a reader must have before moving on with the chapters. This book is a must for any application developer who intends to interact with databases using C# 2008 as the development tool; if this is you, then this book is a must.

What This Book Covers
This book covers Visual Studio 2008, SQL Server 2005, C# 2008, LINQ, and ADO.NET 3.5. All these topics are covered in the form of chapters that explain these tools and technologies using various concepts and code examples. We also modeled the applications used in this book on real-life applications, so you can utilize the concepts that you will learn throughout this book in your professional life.

How This Book Is Organized
This book is organized in such a way that concepts in each chapter are built upon in subsequent chapters. We also tried to make chapters self-contained, so the reader can concentrate on the chapter at hand rather than switching focus among the hapters to understand the concepts. The concepts explained in each chapter are demonstrated with code examples in the “Try It Out” sections, which are usually followed by “How It Works” sections that will help you understand each code statement and its purpose.

Table of Contents

CHAPTER 1 Getting Your Tools
Obtaining Visual Studio 2008
Installing SQL Server Management Studio Express
Installing the Northwind Sample Database
Installing the Northwind Creation Script
Creating the Northwind Sample Database
Installing the AdventureWorks Sample Database
Installing the AdventureWorks Creation Script
Creating the AdventureWorks Sample Database
Summary

CHAPTER 2 Getting to Know Your Tools
Microsoft .NET Framework Versions and the Green Bit and
Red Bit Assembly Model
Using Microsoft Visual Studio 2008
Try It Out: Creating a Simple Console Application Project
Using Visual Studio 2008
How It Works
Using SQL Server Management Studio Express
Summary

CHAPTER 3 Getting to Know Relational Databases
What Is a Database?
Choosing Between a Spreadsheet and a Database
Why Use a Database?
Benefits of Using a Relational Database Management System
Comparing Desktop and Server RDBMS Systems
Desktop Databases
Server Databases
The Database Life Cycle
Mapping Cardinalities
Understanding Keys
Primary Keys
Foreign Keys
Understanding Data Integrity
Entity Integrity
Referential Integrity
Normalization Concepts
Drawbacks of Normalization
Summary

CHAPTER 4 Writing Database Queries
Comparing QBE and SQL
Beginning with Queries
Try It Out: Running a Simple Query
How It Works
Common Table Expressions
Try It Out: Creating a CTE
How It Works
GROUP BY Clause
Try It Out: Using the GROUP BY Clause
How It Works
PIVOT Operator
Try It Out: Using the PIVOT Operator
How It Works
ROW_NUMBER() Function
Try It Out: Using the ROW_NUMBER() Function
How It Works
PARTITION BY Clause
Try It Out: Using the PARTITION BY Clause
How It Works
Pattern Matching
Try It Out: Using the % Character
How It Works
Try It Out: Using the _ (Underscore) Character
How It Works
Try It Out: Using the [ ] (Square Bracket) Characters
How It Works
Try It Out: Using the [^] (Square Bracket and Caret)
Characters
How It Works
Aggregate Functions
Try It Out: Using the MIN, MAX, SUM, and AVG Functions
How It Works
Try It Out: Using the COUNT Function
How It Works
DATETIME Functions.
Try It Out: Using T-SQL Date and Time Functions
How It Works
Joins
Inner Joins
Outer Joins
Other Joins
Summary

CHAPTER 5 Manipulating Database Data
Retrieving Data
Try It Out: Running a Simple Query
How It Works
Using the WHERE Clause
Sorting Data
Using SELECT INTO Statements
Try It Out: Creating a New Table
How It Works
Try It Out: Using SELECT INTO to Copy Table Structure
How It Works
Inserting Data
Try It Out: Inserting a New Row
How It Works
Updating Data
Try It Out: Updating a Row
How It Works
Deleting Data
Summary

CHAPTER 6 Using Stored Procedures
Creating Stored Procedures
Try It Out: Working with a Stored Procedure in SQL Server
How It Works
Try It Out: Creating a Stored Procedure with an
Input Parameter
How It Works
Try It Out: Creating a Stored Procedure with an
Output Parameter
How It Works
Modifying Stored Procedures
Try It Out: Modifying the Stored Procedure
How It Works
Displaying Definitions of Stored Procedures
Try It Out: Viewing the Definition of Your Stored Procedure
How It Works
Renaming Stored Procedures
Try It Out: Renaming a Stored Procedure
How It Works
Working with Stored Procedures in C#
Try It Out: Executing a Stored Procedure with
No Input Parameters
How It Works
Try It Out: Executing a Stored Procedure with Parameters
How It Works
Deleting Stored Procedures
Try It Out: Deleting a Stored Procedure
How It Works
Summary

CHAPTER 7 Using XML
Defining XML
Why XML?.
Benefits of Storing Data As XML
Understanding XML Documents
Understanding the XML Declaration
Converting Relational Data to XML
Using FOR XML RAW
Using FOR XML AUTO
Using the xml Data Type
Try It Out: Creating a Table to Store XML
How It Works
Try It Out: Storing and Retrieving XML Documents
How It Works
Summary

CHAPTER 8 Understanding Transactions
What Is a Transaction?
When to Use Transactions
Understanding ACID Properties
Transaction Design
Transaction State
Specifying Transaction Boundaries
T-SQL Statements Allowed in a Transaction
Local Transactions in SQL Server 2005
Distributed Transactions in SQL Server 2005
Guidelines to Code Efficient Transactions
How to Code Transactions
Coding Transactions in T-SQL
Coding Transactions in ADO.NET
Summary

CHAPTER 9 Getting to Know ADO.NET
Understanding ADO.NET
The Motivation Behind ADO.NET
Moving from ADO to ADO.NET
ADO.NET Isn’t a New Version of ADO
ADO.NET and the .NET Base Class Library
Understanding ADO.NET Architecture
Working with the SQL Server Data Provider
Try It Out: Creating a Simple Console Application
Using the SQL Server Data Provider
How It Works
Working with the OLE DB Data Provider
Try It Out: Creating a Simple Console Application
Using the OLE DB Data Provider
How It Works
Working with the ODBC Data Provider
Creating an ODBC Data Source
Try It Out: Creating a Simple Console Application
Using the ODBC Data Provider
How It Works
Data Providers Are APIs
Summary

CHAPTER 10 Making Connections
Introducing the Data Provider Connection Classes
Connecting to SQL Server Express with SqlConnection
Try It Out: Using SqlConnection
How It Works
Debugging Connections to SQL Server
Security and Passwords in SqlConnection
How to Use SQL Server Security
Connection String Parameters for SqlConnection
Connection Pooling
Improving Your Use of Connection Objects
Using the Connection String in the Connection Constructor
Displaying Connection Information
Connecting to SQL Server Express with OleDbConnection
Try It Out: Connecting to SQL Server Express with the
OLE DB Data Provider
How It Works
Summary

CHAPTER 11 Executing Commands
Creating a Command
Try It Out: Creating a Command with a Constructor
How It Works
Associating a Command with a Connection
Assigning Text to a Command
Executing Commands
Try It Out: Using the ExecuteScalar Method
How It Works
Executing Commands with Multiple Results
Try It Out: Using the ExecuteReader Method
How It Works
Executing Statements
Try It Out: Using the ExecuteNonQuery Method
How It Works
Command Parameters
Try It Out: Using Command Parameters
How It Works
Summary

CHAPTER 12 Using Data Readers
Understanding Data Readers in General
Try It Out: Looping Through a Result Set
How It Works
Using Ordinal Indexers
Using Column Name Indexers
Using Typed Accessor Methods
Getting Data About Data
Try It Out: Getting Information About a Result Set with a
Data Reader
How It Works
Getting Data About Tables
Try It Out: Getting Schema Information
How It Works
Using Multiple Result Sets with a Data Reader
Try It Out: Handling Multiple Result Sets
How It Works
Summary

CHAPTER 13 Using Datasets and Data Adapters
Understanding the Object Model
Datasets vs. Data Readers
A Brief Introduction to Datasets
A Brief Introduction to Data Adapters
A Brief Introduction to Data Tables, Data Columns,
and Data Rows
Working with Datasets and Data Adapters
Try It Out: Populating a Dataset with a Data Adapter
How It Works
Filtering and Sorting in a Dataset
Comparing FilterSort to PopDataSet
Using Data Views
Modifying Data in a Dataset
Propagating Changes to a Data Source
UpdateCommand Property
InsertCommand Property
DeleteCommand Property
Command Builders
Concurrency
Using Datasets and XML
Try It Out: Extracting a Dataset to an XML File
How It Works
Using Data Tables Without Datasets
Try It Out: Populating a Data Table with a Data Adapter
How It Works
Understanding Typed and Untyped Datasets
Summary

CHAPTER 14 Building Windows Forms Applications
Understanding Windows Forms
User Interface Design Principles
Best Practices for User Interface Design
Simplicity
Position of Controls
Consistency
Aesthetics
Color
Fonts
Images and Icons
Working with Windows Forms
Understanding the Design and Code Views
Sorting Properties in the Properties Window
Categorized View
Alphabetical View
Setting Properties of Solutions, Projects, and Windows Forms
Working with Controls
Try It Out: Working with the TextBox and Button Controls
How It Works
Setting Dock and Anchor Properties
Dock Property.
Anchor Property .
Try It Out: Working with the Dock and Anchor Properties
How It Works
Adding a New Form to the Project
Try It Out: Adding a New Form to the Windows Project
Try It Out: Setting the Startup Form
How It Works
Implementing an MDI Form
Try It Out: Creating an MDI Parent Form with a Menu Bar
Try It Out: Creating an MDI Child Form and Running an
MDI Application
How It Works
Summary

CHAPTER 15 Building ASP.NET Applications
Understanding Web Functionality
The Web Server
The Web Browser and HTTP
Introduction to ASP.NET and Web Pages
Understanding the Visual Studio 2008 Web Site Types
File System Web Site
FTP Web Site
HTTP Web Site
Layout of an ASP.NET Web Site
Web Pages
Application Folders
The web.config File
Try It Out: Working with a Web Form
Try It Out: Working with Split View
Using Master Pages
Try It Out: Working with a Master Page
Summary

CHAPTER 16 Handling Exceptions
Handling ADO.NET Exceptions
Try It Out: Handling an ADO.NET Exception (Part 1)
How It Works
Try It Out: Handling an ADO.NET Exception (Part 2)
How It Works
Handling Database Exceptions
Try It Out: Handling a Database Exception (Part 1):
RAISERROR
How It Works
Try It Out: Handling a Database Exception (Part 2):
Stored Procedure Error
How It Works
Try It Out: Handling a Database Exception (Part 3):
Errors Collection
How It Works
Summary

CHAPTER 17 Working with Events
Understanding Events
Properties of Events
Design of Events
Common Events Raised by Controls
Event Generator and Consumer
Try It Out: Creating an Event Handler
How It Works
Try It Out: Working with Mouse Movement Events
How It Works
Try It Out:Working with the Keyboard’s KeyDown and
KeyUp Events
How It Works
Try It Out: Working with the Keyboard’s KeyPress Event
How It Works
Summary

CHAPTER 18 Working with Text and Binary Data
Understanding SQL Server Text and Binary Data Types
Storing Images in a Database
Try It Out: Loading Image Binary Data from Files
How It Works
Rerunning the Program
Retrieving Images from a Database
Try It Out: Displaying Stored Images
How It Works
Working with Text Data
Try It Out: Loading Text Data from a File
How It Works
Retrieving Data from Text Columns
Summary

CHAPTER 19 Using LINQ
Introduction to LINQ
Architecture of LINQ
LINQ Project Structure
Using LINQ to Objects
Try It Out: Coding a Simple LINQ to Objects Query
How It Works
Using LINQ to SQL
Try It Out: Coding a Simple LINQ to SQL Query
How It Works
Try It Out: Using the where Clause
How It Works
Using LINQ to XML
Try It Out: Coding a Simple LINQ to XML Query
How It Works
Summary

CHAPTER 20 Using ADO.NET 3.5
Understanding ADO.NET 3.5 Entity Framework
Understanding the Entity Data Model
Working with the Entity Data Model
Try It Out: Creating an Entity Data Model
How It Works
Try It Out: Schema Abstraction Using an Entity Data Model
Summary

Journey through .NET 1.0 to .NET 3.5

January 10th, 2008 | Posted by Vidya Vrat in .NET - (0 Comments)

.NET Framework has covered long path and .NET 3.5 is available for developers. In the similar fashion Visual Studio 2008 has also been developed each time to accompany the newly developed .NET Framerowk version.

Lets understand about these evolution of various .NET Framework versions and Visual Studio suite.

.NET Framework –|—Year—-|—CLR—|——-Supported VS
—————————————————————————————-
.NET 1.0 ————-2001——-1.0.3705——Visual Studio 2002(Rainer)
.NET 1.1————–2002——-1.1.4322——Visual Studio 2003(Everett)
.NET 2.0————-2005——-2.0.50727—-Visual Studio 2005(Whidbey)
.NET 3.0————-2006——-2.0.50727—-VS 2005 extensions for.NET 3.0
.NET 3.5————-2008——-2.0.50727—-Visual Studio 2008 (Orcas)
——————————————————————————————–

.NET 3.0 comes with following brand new features:
* WPF(Windows Presentation Foundation)
* WCF (Windows Communication Foundation)
* WWF or WF(Windows Workflow Foundation)
*WC (Windows Cardspace)

.NET 3.5 comes with following brand new features:
*LINQ (Language Integrated Query)
*ADO .NET 3.5 with Entity Framework
*ASP.NET 3.5

Location of .NET 3.5 Specific Assemblies

December 23rd, 2007 | Posted by Vidya Vrat in .NET - (0 Comments)

Once you have Visual Studio 2008 in your machine, the folder location of .NET 3.5 related assemblies for LINQ and ADO.NET 3.5 etc will be on a different location than the traditional location C:\WINDOWS\Microsoft.NET\Framework
of all other .NET Framework deployments in your machine

The .NET 3.5 specific assemblies can be found at the location as shown in the figure below

Recently I got an opportunity to review the .NET Preparation Kits produced by uCertify – The fastest way to IT Certification

I was tasked to review the MCTS 70-536 C# exam preparation kit titled: Microsoft .NET Framework 2.0 Application Development Foundation. While reviewing the preparation kit for 70-536 I found the methodology used to teach the concepts are very good and the concepts are covered in such a way that a beginner or a professional will be equally benefited.
Various types of practice tests helps you to be tough and well prepared when you appear for the real test. Each test covers all the concepts as per the Microsoft requirements and helps to prepare gradually and also to see your progress. I believe that this exam is one of the most usable exams as it opens the entry for three other MCTS exams as well. I personally feel, that Investing in 70-536 preparation kit available at 70-536-CSHARP – C#.NET 2.0 Application Development Foundation practice test will be an asset for any MCTS aspitant.

If you want to purchase .NET Preparation kits from uCertify then you can avail 10% discount as being my blog reader. Provide the discount code “VVRAGA” during your online purchase order when asked and enjoy the .NET Preparation kits to help you achieve your desired Microsoft certification.

Lets also have look at the user friendly and easy to use dashboard of uCertify’s preparation kits.

1.Build Applications which can run on and support Multiple versions of the .NET Framework
2.LINQ support to work with Data in a Unified and Integrated way
3.Support to Build Office 2003/2007 based Applications.
4.Amazing Unit Testing support on right click in the code view and dedicated Test Project Template.
5.Ground level support for Windows Vista Applications
6.SilverLight can be done here, which seems to be the latest WEB User Interface Technique
7.Facinating enough to have dedicated Project Templates for WPF, WCF and Workflow

VS 2008 RTM is availabe to download for MSDN Subscribers
Get VS 2008

If you recall previous releases of .NET Framework which had a dedicated Visual Studio.NET linked to that particular .NET Framework version.

Lets see, all of them again:-

Microsoft .NET Framework | Visual Studio .NET
————————————————————–
1- .NET 1.0 ———————- Visual Studio 2002
2- .NET 1.1 ———————- Visual Studio 2003
3- .NET 2.0 ———————- Visual Studio 2005
4. .NET 3.0 ———————- VS 2005 + VS 2005 extensions for .NET 3.0
5. .NET 3.5 ———————- Visual Studio 2008

This coupling in between has just put the entire Microsoft .NET aspirants to shift their focus to different IDEs and interfaces time to time for almost six years by now.

Visual Studio 2008(code named Orcas) is designed with a vision to support any .NET Framework version application in its single IDE, I.e, you don’t need multiple copies of VS .NET to support different versions of .NET Framework (as shown above). Hence the Visual Studio 2008 reduces or removes the coupling between .NET Framework and Visual Studio .NET, and having just one copy of Visual Studio 2008 will cater the various .NET Framework versions.

The Visual Studio 2008 Projects Templates and how they support to .NET Framework versions is shown in the figure here:

 

You can see the vast range of Project Templates VS 2008 supports. Beisides on the top right corner of the figure shown just above, you can see while choosing a project template, it also allows you to choose your desired .NET Framework version from the dropdown list.

Hence, Visual Studio 2008 and its support for multiple .NET version support minimizes the maintenance and side-by-side issues which we all were facing due to the coupling betwenn VS.NET and their respective .NET Framework versions.

As Orcas targets/supports various .NET Framework versions installed and that could have been achieved by installing one .NET Framework version on the top of another version. For example, .NET 3.0 installed on .NET 2.0, and then .NET 3.5 on .NET 3.0.

The .NET 3.5 Framework version holds green bit assemblies which are additional assemblies and can be installed at the top of other existing .NET Framework assemblies.

Green bit assemblies when installed, they don’t affect existing assemblies. For example, .NET 3.0 when installed on .NET 2.0, it does not affect .NET 2.0 assemblies.

In the similar manner, .NET 3.5 assemblies does not affect the framework version either 2.0 or 3.0 on the top of which you will be installing it. You can see in Figure 2-2 that .NET 3.5 implements Green bit assemblies in the Microsoft .NET Framework 3.5 (Pre-Release Version) folder.

Whereas Red bit assemblies are the assemblies which ship either as part of the platform or part of a development tool. For example, Windows Vista ships WPF, WCF etc, and Visual Studio 2005 ships .NET 2.0. Besides assemblies delivered as service packs, hot fixes or updates are also considered as Red bit assemblies.