Programming Microsoft LINQ in Microsoft .NET Framework 4
With LINQ, you can query data from a variety of sources—including databases, objects, and XML files—directly from Microsoft Visual Basic or C#. Guided by data-access experts who’ve worked in depth with LINQ and the Microsoft development teams, Programming Microsoft LINQ in Microsoft .NET Framework 4 will show you how .NET Framework 4 implements LINQ, and how to exploit it. Clear examples show you how to deliver your own data-access solutions faster and with leaner code.
Discover how to:
(1) Use LINQ to query databases, object collections, arrays, XML, Microsoft Excel® files, and other sources
(2) Apply LINQ best practices to build data-enabled .NET applications and services
(3) Manipulate data in a relational database with ADO.NET Entity Framework or LINQ to SQL
(4) Read, write, and manage XML content more efficiently with LINQ to XML
(5) Extend LINQ to support additional data sources by creating custom operators and providers
(6) Examine other implementations, such as LINQ to SharePoint®
(7) Use LINQ within the data, business, and service layers of a distributed application
(8) Get code samples on the Web
About the Authors
Paolo Pialorsi is a consultant, trainer, and author who specializes in developing distributed applications architectures and Microsoft SharePoint enterprise solutions. He is a founder of DevLeap, a company focused on providing content and consulting to professional developers. Paolo wrote “Programming Microsoft LINQ” and “Introducing Microsoft LINQ” both published by Microsoft Press, and is the author of three books in Italian language about XML and Web Services. He is also a regular speaker at industry conferences.
Marco Russo is a founder of DevLeap. He is a regular contributor to developer user communities and is an avid blogger on Microsoft SQL Server Business Intelligence and other Microsoft technologies. Marco provides consulting and training to professional developers on the Microsoft .NET Framework and Microsoft SQL Server. He wrote “Programming Microsoft LINQ” and “Introducing Microsoft LINQ” with Paolo Pialorsi, “Expert Cube Development with Microsoft SQL Server 2008 Analysis Services” with Alberto Ferrari and Chris Webb, and is the author of two books in Italian about C# and the common language runtime
Programming Microsoft LINQ in Microsoft .NET Framework 4
Publisher: Microsoft Press
By Paolo Pialorsi, Marco Russo
Print ISBN: 9780735640573
Ebook ISBN: 9780735640566
Pages: 704
About Microsoft Press
Microsoft Press is a division of Microsoft Corporation. Established in 1985, Microsoft Press publishes self-paced learning materials on Microsoft products and associated technologies. Microsoft Press products are available in a variety of formats for individual users, IT professionals, and developers. Since 2009, Microsoft and O’Reilly Media have shared the editorial direction and development of Microsoft Press products. O’Reilly also handles sales, distribution, customer service, and some administrative functions.
Categories: linq Tags: linq, Programming Microsoft LINQ in Microsoft .NET Framework 4
Dot Net Development: LINQ improves the productivity of a developer
Microsoft Language Integrated Query (LINQ) offers developers a latest way to query data using strongly-typed queries and strongly-typed results, frequent across a number of dissimilar data types including relational databases, .NET objects, and XML. With the help of strongly-typed queries and results, LINQ improves the productivity of a developer with the benefits of IntelliSense and compile-time error checking.
LINQ to SQL
LINQ to SQL is an object-relational mapping (ORM) framework which ensures the direct 1-1 mapping of a Microsoft SQL Server database to .NET classes, and query of the resultant objects using LINQ. More specifically, LINQ to SQL has been developed with a goal to rapidly develop the scenario against Microsoft SQL Server where the database is very similar to the application object model and the primary concern is amplified developer productivity.
LINQ to Entities
LINQ to Entities is, exclusively, a part of the ADO.NET Entity Framework which permits LINQ query capabilities. The Entity Framework is the fruition of ADO.NET that enables developers to program in terms of the standard ADO.NET abstraction or in terms of persistent objects (ORM) and is built upon the standard ADO.NET Provider model that ensures an access to third party databases. The Entity Framework harbingers a new set of services around the Entity Data Model (EDM).
LINQ to DataSet
LINQ is one of the best ways to make queries and set based operations first class citizens in the .NET world. It enables queries to be printed in the development language, and provides compile time type checking. In addition, LINQ ensures full power of the framework to be used when writing queries. LINQ to DataSets bestows this power to your DataSet based application.
Technical Articles
The major scenarios for which each of these technologies have been designed:
Webcasts: It is the Entity Framework for Database Administrators (Level 200) which is a new data technology from Microsoft that may chiefly rouse the interest of database administrators (DBAs).
Framework Masterclass: LINQ to SQL (Level 200) is a Microsoft .NET Language Integrated Query (LINQ) that provides a familiar way to work with data in your applications.
Introducing LINQ to DataSet (Level 200):
Exploration of new technologies within Microsoft Visual Studio code name “Orcas” make working with data a better practice. One such technology is Microsoft .NET Language Integrated Query (LINQ), code name for a set of extensions to the Microsoft .NET Framework that include language-integrated data query, set, and change operations.
Microsoft Language Integrated Query (LINQ) makes way for the dot net development a latest way to query data using strongly-typed queries and strongly-typed results.
Tyler Moon is an expert in article writing and internet marketing. She regularly contributes articles on various topics like security services, birth announcements etc.
Article from articlesbase.com
Find More LINQ Articles
Categories: linq Tags: developer, Development, improves, linq, productivity
Linq Projection in Vb
This tutorial was created with Microsoft Visual Stuio.NET 2008. 2005 can be used, but you must install Microsoft’s LINQ Community Technology Preview release.
In this tutorial we will look at LINQ Projection, which is when we can select specific data from a source without retrieving all fields. We will be creating a class to define a list in which we will create a number of people with IDs, names and cities. Then we will use buttons to select only parts of this data.
First, we will start off by creating a new Windows Form application in VS.NET 2008. Next, we will create a class – call it aList – and define our list object:
Public Class aList
Private _personID As Integer
Private _name As String
Private _city As String
Public Property PersonID() As Integer
Get
Return _personID
End Get
Set(ByVal value As Integer)
_personID = value
End Set
End Property
Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Public Property City() As String
Get
Return _city
End Get
Set(ByVal value As String)
_city = value
End Set
End Property
End Class
This class defines a Property for each field we want, and its data type.
Next, we can add our Controls to the Form. We will add three buttons, and a Rich TextBox. The buttons will retrieve all of the IDs, Names and Cities, individually. This will demonstrates how we can retrieve the specific data that we want. Once we have our controls, we can move onto the code-behind of the form and define our data. We will add a few sample entries:
Please visit Linqhelp.com to complete this article. Happy Coding!
Article from articlesbase.com
Categories: linq Tags: linq, Projection
Linq Projection in C#
In this tutorial we will look at LINQ Projection, which is when we can select specific data from a source without retrieving all fields. We will be creating a class to define a list in which we will create a number of people with IDs, names and cities. Then we will use buttons to select only parts of this data.
First, we will start off by creating a new Windows Form application in VS.NET 2008. Next, we will create a class – call it aList – and define our list object:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LINQProjection_cs
{
class aList
{
private int _personID;
private string _name;
private string _city;
public int PersonID
{
get
{
return _personID;
}
set
{
_personID = value;
}
}
public string Name
{
get
{
return _name;
}
set
{
_name = value;
}
}
public string City
{
get
{
return _city;
}
set
{
_city = value;
}
}
}
}
This class defines a Property for each field we want, and its data type.
Next, we can add our Controls to the Form. We will add three buttons, and a Rich TextBox. The buttons will retrieve all of the IDs, Names and Cities, individually. This will demonstrates how we can retrieve the specific data that we want. Once we have our controls, we can move onto the code-behind of the form and define our data. We will add a few sample entries:
Please vist LinqHelp.com to complete this article. Happy coding!
Article from articlesbase.com
Categories: linq Tags: linq, Projection
Creating Linq to Sql Entities in C#
This tutorial was created with Visual Studio .NET 2008, but can be recreated in 2005, after downloading and installing Microsoft’s LINQ Community Technology Preview release, which can be downloaded from here.
Visual Studio.NET 2008 makes it very easy for us to create LINQ to SQL Entities using the Object Relational Designer. What it does is creates classes and methods that relate to the database columns and tables. This makes it possible for us to communicate with the data using LINQ (Language Integrated Query).
This tutorial will show how we can bypass the Designer and write the class ourselves, so that we get a better understanding of what’s going on. For this example, we will be using a SQL database with one table and three columns – id, name, and city.
Once we have our database set up, we will create a new class to represent the database table structure. It should look something like this:
using System;
using System.Data.Linq.Mapping;
[Table(Name="tblPeople")]
public class people
{
[Column(IsPrimaryKey=true, IsDbGenerated=true)]
public int Id { get; set; }
[Column(CanBeNull=true)]
public string name { get; set; }
[Column(CanBeNull=true)]
public string city { get; set; }
public people()
{
}
}
It is advised to always include the table name in the class, although it is not really required if the class is named the same as the table in the SQL database. You should always declare the Primary Key, especially if you are planning on making changes to the database. IsDbGenerated is also used where the database will auto-generate the values upon insert.
In the class, we need to define a [Column] for each in the database table, and then the name of the column should be represented by the public string (or int, etc.)
Next, we are going to display the data with a GridView, and we will also add a textbox and button to the page to allow searching of the database.
Our ASPX page will look something like this:
For the full article please visit LinqHelp.com. Happy Coding!
Article from articlesbase.com
Creating Linq to Sql Entities in Vb.net
This tutorial was created with Visual Studio .NET 2008, but can be recreated in 2005, after downloading and installing Microsoft’s LINQ Community Technology Preview release, which can be downloaded from here.
Visual Studio.NET 2008 makes it very easy for us to create LINQ to SQL Entities using the Object Relational Designer. What it does is creates classes and methods that relate to the database columns and tables. This makes it possible for us to communicate with the data using LINQ (Language Integrated Query).
This tutorial will show how we can bypass the Designer and write the class ourselves, so that we get a better understanding of what’s going on. For this example, we will be using a SQL database with one table and three columns – id, name, and city.
Once we have our database set up, we will create a new class to represent the database table structure. It should look something like this:
Imports System
Imports System.Data.Linq.Mapping
_
Public Class people
Private _Id As Integer
Private _name As String
Private _city As String
_
Public Property Id() As Integer
Get
Return _Id
End Get
Set(ByVal value As Integer)
_Id = value
End Set
End Property
_
Public Property name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
_
Public Property city() As String
Get
Return _city
End Get
Set(ByVal value As String)
_city = value
End Set
End Property
End Class
It is advised to always include the table name in the class, although it is not really required if the class is named the same as the table in the SQL database. You should always declare the Primary Key, especially if you are planning on making changes to the database. IsDbGenerated is also used where the database will auto-generate the values upon insert.
In the class, we need to define a [Column] for each in the database table, and then the name of the column should be represented by the public string (or int, etc.)
Next, we are going to display the data with a GridView, and we will also add a textbox and button to the page to allow searching of the database.
Our ASPX page will look something like this:
For the full article please visit LinQhelp.com. Thanks and happy coding!
http://www.linqhelp.com
Article from articlesbase.com
Find More LINQ Articles
Using Linq to Objects in C#
This tutorial was created with Microsoft Visual Studio .NET 2008. However, if you are using 2005, you can implement LINQ by downloading Microsoft’s LINQ Community Technology Preview release from here.
In this tutorial, we will be looking at using LINQ to Objects. We will be creating a Windows Forms Application that will first define an array of numbers, and then we will use LINQ to Objects to interact with this collection of numbers. We will create buttons to display the results of calculations of the numbers, demonstrating the built-in functions of LINQ, that we can perform on most any collection.
We will start by designing our form with Four buttons and a label. The first button will be to display all the numbers in our array, which we will hard-code for this example. The label will be to show the results of our functions, and then the other three buttons we will use for LINQ functions.
We will also implement a StatusStrip control to make use of the label within, so that we can manipulate it on the mouse hover and leave events. The form may look something like this:
Once we are done with our form, we can double-click on the buttons in design view to create the click event handlers. We can also create the hover and leave handlers by clicking on the Events button in the Properties window, and then double-clicking on both of the MouseHover and MouseLeave events.
Let’s start with the statusstrip label. We will change the text on hover and leave of each of the buttons to let the user know what each of the buttons does:
private void button1_MouseHover(object sender, EventArgs e)
{ toolStripStatusLabel1.Text = “Display all numbers in array”; }
private void button1_MouseLeave(object sender, EventArgs e)
{ toolStripStatusLabel1.Text = “”; }
private void button3_MouseHover(object sender, EventArgs e)
{ toolStripStatusLabel1.Text = “Get SUM of all numbers”; }
private void button3_MouseLeave(object sender, EventArgs e)
{ toolStripStatusLabel1.Text = “”; }
private void button2_MouseHover(object sender, EventArgs e)
{ toolStripStatusLabel1.Text = “Get numbers less than 10″; }
private void button2_MouseLeave(object sender, EventArgs e)
{ toolStripStatusLabel1.Text = “”; }
private void button4_MouseHover(object sender, EventArgs e)
{ toolStripStatusLabel1.Text = “Get average of numbers”; }
private void button4_MouseLeave(object sender, EventArgs e)
{ toolStripStatusLabel1.Text = “”; }
Next, we will create a method that will create an array of numbers that we can call from all of the buttons:
You can review the rest of the articlie at LinQhelp.com Happy coding!
Article from articlesbase.com
More LINQ Articles
How to Keep Linq to Sql Classes in Sync With Database Structure
About Linq To Sql
Since it became available developers using .Net have no need to mix code with SQL commands within the application to access database objects. Now developers can access data in databases using programming language they get used to (C#, VB.NET). Moreover, using LINQ To SQL allows developer to uniformly manage all iterative data sources: databases, XML, various collections, etc. In addition you get code verification during compilation, full integration in Visual Studio which provides many advantages: IntelliSense, database model designer, auto generation of code by the model and so on.
Nothing is ideal
And still in spite of all advantages of using LINQ To SQL, its usage in real large projects is complicated for some problems. Using LINQ To SQL in the project will make you use such Visual Studio component as LINQ To SQL Classes. The component is not easy to use as it should be kept in sync with the structure of real database.
The variant of synchronizing LINQ To SQL Classes and database structure in manual mode is not considered at all due to huge work content and possibility of errors. Nevertheless, it is very important to keep LINQ To SQL Classes in sync with database structure, as LINQ To SQL Classes and database structure are often modified during software design.
Database Restyle – Library will solve the problem of the modifications transference from LINQ To SQL Classes to database structure.
In order to solve the first problem mentioned in the previous chapter, Perpetuum Software LLC developed the PerpetuumSoft.DataModel.LinqToSql library. This library allows the propagation of changes from LINQ To SQL to database structure without database re-creation. This library is based on another more functional Database Restyle library designed to synchronize two databases. Thus, you will have an opportunity to extend the standard abilities of the LINQ to SQL technology and avoid problems with synchronization of LINQ To SQL Classes with database structure.
The full article is available:
http://www.perpetuumsoft.com/Product.aspx?lang=en&pid=55&tid=linqtosqlsynchronization&dbrl
Perpetuum Software LLC specializes in development of high-quality .NET and ASP.NET software components compatible with MS Visual Studio .NET, C# Builder, Delphi .NET and other IDEs supporting .NET Framework. Such use-proven components as Report Sharp-Shooter, Instrumentation ModelKit, OLAP ModelKit, Chart ModelKit, the .NET Dashboard Suite, OLAP + CHART ModelKit and other .NET components by Perpetuum Software LLC are already well known on the software development market and are used by developers in more than 60 countries.
Article from articlesbase.com
Find More LINQ Articles