June 2008 - Posts
Language Integrated Query
Language Integrated Query (LINQ, pronounced "link") is a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages using a syntax reminiscent of SQL. Many of the concepts that LINQ has introduced were originally tested in Microsoft's Cω research project. LINQ was released as a part of .NET Framework 3.5 on November 19, 2007.
LINQ defines a set of query operators that can be used to query, project and filter data in arrays, enumerable classes, XML, relational database, and third party data sources. While it allows any data source to be queried, it requires that the data be encapsulated as objects. So, if the data source does not natively store data as objects, the data must be mapped to the object domain. Queries written using the query operators are executed either by the LINQ query processing engine or, via an extension mechanism, handed over to LINQ providers which either implement a separate query processing engine or translate to a different format to be executed on a separate data store (such as on a database server as SQL queries). The results of a query are returned as a collection of in-memory objects that can be enumerated.
Language-Integrated Query (LINQ) is a groundbreaking innovation in Visual Studio 2008 and the .NET Framework version 3.5 that bridges the gap between the world of objects and the world of data.

Traditionally, queries against data are expressed as simple strings without type checking at compile time or IntelliSense support. Furthermore, you have to learn a different query language for each type of data source: SQL databases, XML documents, various Web services, and so on. LINQ makes a query a first-class language construct in C# and Visual Basic. You write queries against strongly typed collections of objects by using language keywords and familiar operators. The following illustration shows a partially-completed LINQ query against a SQL Server database in C# with full type checking and IntelliSense support.
In Visual Studio you can write LINQ queries in Visual Basic or C# with SQL Server databases, XML documents, ADO.NET Datasets, and any collection of objects that supports IEnumerable or the generic IEnumerable<(Of <(T>)>) interface. LINQ support for the ADO.NET Entity Framework is also planned, and LINQ providers are being written by third parties for many Web services and other database implementations.
You can use LINQ queries in new projects, or alongside non-LINQ queries in existing projects. The only requirement is that the project target version 3.5 of the .NET Framework.

Language Extensions
While LINQ is primarily implemented as a library for .NET Framework 2.0, it also defines a set of language extensions that can be optionally implemented by languages to make queries a first class language construct and provide syntactic sugar for writing queries. These language extensions have initially been implemented in C# 3.0, VB 9.0 and Chrome, with other languages like F# and Nemerle having announced preliminary support. The language extensions include:[2]
· Query syntax: Languages are free to choose a query syntax, which it will recognize natively. These language keywords must be translated by the compiler to appropriate LINQ method calls. The languages can implement operator reordering and other optimizations at the keyword level.
· Implicitly typed variables: This enhancement allows variables to be declared without specifying their types. The languages C# 3.0 and Chrome declare them with the var keyword. In VB9.0, the use of the Dim keyword without type declaration accomplishes the same declaration. Such objects are still strongly typed; for these objects the compiler uses type inference to infer the type of the variables. This allows the result of the queries to be specified and their result defined without declaring the type of the intermediate variables.
· Anonymous types: Anonymous types allow classes, which contain only data member declarations, to be inferred by the compiler. This is useful for the Select and Join operators, whose result types may differ from the types of the original objects. The compiler uses type inference to determine the fields contained in the classes and generates accessors and mutators for these fields.
· Object Initializer: Object initializers allow an object to be created and initialized in a single scope, this allows creation of delegates that extract fields from an object, create a new object and assign the extracted data to the fields of the new object in a single statement, as is required for Select and Join operators.
· Lambda expressions: Lambda expressions are used to create delegates inline with other code. This allows the predicates and extraction functions to be written inline with the queries.

LINQ Providers
LINQ also defines another interface, IQueryable<T>, which defines the same interfaces to the Standard Query Operators as IEnumerable<T>. However, the concrete implementation of the interface, instead of evaluating the query, converts the query expression, with all the operators and predicates, into an expression tree.[3] The Expression tree preserves the high level structure of the query and can be examined at runtime. The type of the source collection defines which implementation will run - if the collection type implements IEnumerable<T>, it executes the local LINQ query execution engine and if it implements the IQueryable<T> implementation, it invokes the expression tree-based implementation. An extension method is also defined for IEnumerable<T> collections to be wrapped inside an IQueryable<T> collection, to force the latter implementation.
The expression trees are at the core of LINQ extensibility mechanism, by which LINQ can be adapted for any data source. The expression trees are handed over to LINQ Providers, which are data source-specific implementations that adapt the LINQ queries to be used with the data source. The LINQ Providers analyze the expression trees representing the query ("query trees") and generate a DynamicMethod (which are methods generated at runtime) by using the reflection APIs to emit CIL code. These methods are executed when the query is run.[3] LINQ comes with LINQ Providers for in-memory object collections, SQL Server databases, ADO.NET datasets and XML documents. These different providers define the different flavors of LINQ:
LINQ to Objects
The LINQ to Objects provider is used for querying in-memory collections, using the local query execution engine of LINQ. The code generated by this provider refer the implementations of the standard query operators as defined in the Sequence class and allows IEnumerable<T> collections to be queried locally.
LINQ to XML
The LINQ to XML provider converts an XML document to a collection of XElement objects, which are then queried against using the local execution engine that is provided as a part of the implementation of the standard query operator.[4]
LINQ to SQL
The LINQ to SQL provider allows LINQ to be used to query SQL Server databases as well as SQL Server Compact databases. Since SQL Server data resides on a remote server, and because it already includes a querying engine, LINQ to SQL does not use the query engine of LINQ. Instead, it converts a LINQ query to SQL query which is then sent to SQL Server for processing.[5] However, since SQL Server stores the data as relational data and LINQ works with data encapsulated in objects, the two representations must be mapped to one another. For this reason, LINQ to SQL also defines the mapping framework. The mapping is done by defining classes which corresponds to the tables in database, and containing all or a subset of the columns in the table as data members.
The correspondence, along with other relational model attributes such as primary keys are specified using LINQ to SQL-defined attributes.
LINQ to DataSets
The LINQ to SQL provider works only with Microsoft SQL Server databases; to support any generic database, LINQ also includes the LINQ to DataSets, which uses ADO.NET to handle the communication with the database. Once the data is in ADO.NET Datasets, LINQ to Datasets execute queries against these datasets.
Other providers
The LINQ providers can be implemented by third parties for various data sources as well. Several database server specific providers are available from the database vendors. Some of the popular providers include:
· Data Services: LINQ to ADO.NET Data Services
· Entity Framework: LINQ to Entities[
· DbLinq: LINQ to MySQL, PostgreSQL, and Oracle
· Google search: LINQ to Google
· Windows Search: LINQ to System Search
OVERVIEW
Microsoft® Visual Studio® 2008 delivers on Microsoft’s vision of smart client applications by enabling developers to rapidly create connected applications that deliver the highest quality, rich user experiences. With Visual Studio 2008, organizations will find it easier than ever before to capture and analyze information to help them make effective business decisions. Visual Studio 2008 enables organizations of every size to rapidly create more secure, manageable, and reliable applications that take advantage of Windows Vista™ and the 2007 Office system. Visual Studio 2008 delivers key advances for developers in three primary pillars:
§ Rapid application development
§ Effective team collaboration
§ Breakthrough user experiences

This blog discusses the different customer experiences that deliver on these three pillars through the following seven technology areas.
§ Developing Smart Client Applications. Visual Studio 2008 delivers new and easy ways for developers to build smart clients. It provides a comprehensive set of tools and classes that simplify integrating smart clients with new or existing Web applications, and it enables local data caching for disconnected scenarios.
§ Creating Microsoft Office Applications. Visual Studio Tools for Office (VSTO) is fully integrated into Visual Studio 2008 Professional Edition. Developers can now customize various Office applications, such as Outlook® and PowerPoint®, to improve user productivity and simplify deployment.
§ Building Windows Vista Applications. Developers can easily leverage new platform technologies, and deliver more compelling applications to their customers, by effortlessly incorporating new Windows Presentation Foundation features into both existing Windows Forms applications and new applications.
§ Handling Data More Productively. The introduction of Language Integrated Query (LINQ) and other data-access improvements enable developers to apply a consistent programmatic approach to data handling, perform data access with new data-design surfaces, and use built-in classes for the occasionally connected design pattern.
§ Enabling New Web Experiences. Developers can easily create efficient, interactive Web applications with Visual Studio 2008. Seamless integration of the familiar ASP.NET AJAX programming model enables more efficient client-side execution, giving end users a more responsive Web interface. JavaScript IntelliSense and debugging further improve the development experience.
White Paper: An Overview of Microsoft Visual Studio 2008 2
§ Gaining an Improved Overall Developer Experience. Visual Studio 2008 delivers a better developer experience overall through the combination of significant product quality improvements, and changes to the way the most popular design surfaces return errors to the user. In addition, Visual Studio 2008 simplifies the user’s ability to adopt the toolset and framework separately by enabling developers to target different .NET Framework platforms.
§ Improving Application Lifecycle Management (ALM). ALM features in Visual Studio provide great support not only for managing the entire software-development life cycle, but also for critical interaction with an enterprise application’s final end-users and IT stakeholders.
These three pillars in Visual Studio 2008 enable developers to:
§ Rapid Application Development. In Visual Studio 2008, developer productivity doesn’t end with the code editor and wizards. By providing new tools and frameworks to simplify the tasks of developers, designers, and database professionals for new application architectures and platforms, Visual Studio 2008 not only delivers a productive development tool, but also enables developers to tackle new business problems while decreasing the total cost of solution construction.
§ Effective Team Collaboration. Visual Studio 2008 enhances the end-to-end value of Visual Studio Team System by increasing its role-based coverage and delivering enhanced traceability throughout the software development life cycle. With deep integration across roles in the software life cycle and the Team Foundation Server, Team System enables customers to amplify the impact of their teams and improve software quality.
§ Breakthrough User Experience. As users look for new ways to comprehend and retain information, developers must still grapple with basic desktop and application security. Visual Studio, Windows Vista, and the 2007 Office system enable developers to deliver a safe, robust, and compelling user experience in any type of application.
These fundamental advances enable customers to rapidly create connected applications that deliver the highest quality, rich user experiences regardless of project complexity or organization size.
For the latest information about Visual Studio 2008, see the Visual Studio Web site (http://www.microsoft.com/vstudio).
RadControls for ASP.NET AJAX (Prometheus) is Telerik’s next-generation ASP.NET UI control suite, which is built on top of the industry-standard Microsoft ASP.NET AJAX framework. RadControls for ASP.NET AJAX (Prometheus) delivers faster performance, unified programming model and enhanced functionality.
- The new suite includes all controls from RadControls for ASP.NET (Classic), except RadRotator (which will be added with the Q2 2008 release)
- There are 3 new controls - RadScheduler, RadColorPicker, and RadSlider as well as other utilities like RadScriptManager, RadStyleSheetManager and FormDecorator for skinnable buttons, checkboxes and radio buttons
- All Prometheus controls are shipped in a single assembly, which greatly simplifies the deployment
- Due to this architectural change, the new RadControls for ASP.NET AJAX (Prometheus) suite is NOT backwards compatible with RadControls for ASP.NET (Classic)
- The new suite supports ASP.NET 2.0 and ASP.NET 3.5
- If you decide not to upgrade at this point, you can continue using the RadControls for ASP.NET (Classic) in your applications. Telerik will offer product updates and hotfixes for the RadControls for ASP.NET (Classic) and they will be fully supported through at least 2010, after which only “extended support” for the RadControls for ASP.NET (Classic)

Just as ASP.NET AJAX is the future of ASP.NET, RadControls for ASP.NET AJAX represents the future direction of the Telerik web development tools and aims to deliver unmatched richness, reliability and productivity.
RadControls for ASP.NET AJAX offers much more than just support for the “AJAX” part of ASP.NET AJAX. Telerik has been a pioneer in the AJAX space since 2004 and was the first major component vendor to provide ASP.NET AJAX compatibility for its product line. RadControls for ASP.NET AJAX goes a step further. It is entirely built on top of the ASP.NET AJAX framework allowing developers to fully leverage the widely supported client-oriented programming model introduced by Microsoft.
WHY CHOOSE?
1. The most comprehensive toolset – over 20 controls
Telerik RadControls for ASP.NET AJAX include over 20 market leading controls that bring unparalleled richness, responsiveness and interactivity to your web applications.
2. Significantly reduced development time
RadControls have developer-friendly design time support and provide nearly codeless experience for a lot of scenarios. All controls are encapsulated in a single assembly and have a unified programming model which facilitates the deployment and the learning process.
3. Built on top of MS ASP.NET AJAX
Telerik engineered the new RadControls for ASP.NET AJAX on top of Microsoft’s next-generation web framework. The suite takes full advantage of the functionality of the AJAX framework, and delivers previously unattainable performance and features.
4. Unbeatable performance
Telerik RadControls for ASP.NET AJAX offer super-high performance controls without sacrificing the powerful features that you are accustomed to see from us. All controls leverage an innovative load-as-needed script resource handlers, as well as optimized client-side and server-side code for blazing speed.
5. Phenomenal client-side capabilities
RadControls for ASP.NET AJAX allow developers to fully leverage the widely supported client-oriented programming of the ASP.NET AJAX framework. RadControls have a familiar and rich client-side API, guaranteeing full control over various functions performed on the client, such as: ability to bind to web services on the client; rendering on the client; ability to add, modify and remove items on the client and much more.
6. Wide cross-browser compatibility, XHTML & accessibility compliance
RadControls have the widest cross browser compatibility on the component market and all modern browsers are fully supported. The controls also are rendered in clean XHTML for strict W3C standards compliance and are accessible according to both Section 508 and W3C Accessibility Guidelines.
7. VS2008 and ASP.NET 3.5 support
Traditionally, Telerik has always been going hand-in-hand with the latest Microsoft technologies. With the launch of ASP.NET 3.5 and Visual Studio 2008 Telerik is ready with native support for the latest framework and IDE so that you can begin building tomorrow’s solutions today. RadControls for ASP.NET AJAX are available in two versions – one built natively against ASP.NET 2.0/VS 2005 and the other built against ASP.NET 3.5/VS 2008.
8. Sharepoint and DNN
Telerik RadControls include wrappers for Microsoft Office Sharepoint Server (MOSS) and DotNetNuke (DNN). Tailored for seamless integration with SharePoint and DNN, the toolset allows professionals to build web-solutions with the UI richness and responsiveness of desktop apps.
9. Comprehensive Documentation & Learning Materials
Telerik provides superior technical support and a variety of resources: demos, online documentation, tutorials, videos, very active forums, knowledge base articles, code library, sample applications and much more.
http://www.telerik.com/products/aspnet-ajax/overview.aspx
Microsoft .NET Framework is a software component that is a part of several Microsoft Windows operating systems. It has a large library of pre-coded solutions to common programming problems and manages the execution of programs written specifically for the framework. The .NET Framework is a key Microsoft offering and is intended to be used by most new applications created for the Windows platform.
The pre-coded solutions that form the framework's Base Class Library cover a large range of programming needs in a number of areas, including user interface, data access, database connectivity, cryptography, web application development, numeric algorithms, and network communications. The class library is used by programmers who combine it with their own code to produce applications.
Programs written for the .NET Framework execute in a software environment that manages the program's runtime requirements. Also part of the .NET Framework, this runtime environment is known as the Common Language Runtime (CLR). The CLR provides the appearance of an application virtual machine so that programmers need not consider the capabilities of the specific CPU that will execute the program. The CLR also provides other important services such as security, memory management, and exception handling. The class library and the CLR together compose the .NET Framework.
|
Version
|
Version Number
|
Release Date
|
|
1.0
|
1.0.3705.0
|
2002-01-05
|
|
1.1
|
1.1.4322.573
|
2003-04-01
|
|
2.0
|
2.0.50727.42
|
2005-11-07
|
|
3.0
|
3.0.4506.30
|
2006-11-06
|
|
3.5
|
3.5.21022.8
|
2007-11-19
|
NET Framework 3.5
Version 3.5 of the .NET Framework was released on November 19, 2007, and is included with Windows Server 2008. As with .NET Framework 3.0, version 3.5 uses the CLR of version 2.0. In addition, it installs .NET Framework 2.0 SP1 and .Net Framework 3.0 SP1, which adds some methods and properties to the BCL classes in version 2.0 which are required for version 3.5 features such as Language Integrated Query (LINQ). These changes do not affect applications written for version 2.0, however.
As with previous versions, a new .NET Compact Framework 3.5 was released in tandem with this update in order to provide support for additional features on Windows Mobile and Windows Embedded CE devices.
There are two elements that make up version 3.5 of the Framework: the "green bits" and the "red bits". This model is aimed at minimizing the impact of delivering new features and functionality. The red bits are those parts of the Framework that exist in release today, which include the .NET Framework 2.0 and 3.0 releases. The green bits are brand new assemblies with brand new types in them.

Looking at the diagram above, you might notice that the full version number for the .NET Framework v2.0 bits is different across the different versions. The important thing to understand here is how Microsoft views version numbers. In the Microsoft world, the version number is the first three parts - the Major.Minor.Build parts. The fourth part is the Revision, which corresponds to the service pack level.
The end result of this is that the .NET Framework v3.0 is at a different service pack on Vista then it is on other versions of Windows. The .NET Framework v3.5 includes updates to both the v2.0 and v3.0 frameworks. These updates are not new changes or features, but are really a service pack with bug fixes and performance improvements.
The .NET Framework 3.5 brings no breaking changes. New technology is being added including LINQ, AJAX, WF, WCF and WPF Developer Tools and BCL enhancements.
.NET Framework 3.5 New Features
Faster .NET Framework execution
1. Faster garbage collection
2. Smarter, faster NGen requiring smaller working set RAM
3. 64 bit client improvements
4. ThreadPool performance improvements
5. Security check caching during NGen
Base Class Library – New Class Additions
6. BigInteger, HashSet and DateTime2 types
7. NSA Suite ”B” and FIPs compliant cryptography
8. Lightweight Reader/Writer Lock Classes
9. Anonymous and Named Pipes IO Classes
10. Integration with Event Tracing for Windows
11. New Adding hosting model for extensibility
Language Integrated Query (LINQ)
Deep integration of LINQ data-awareness into the programming languages and framework.
Workflow Enabled Services – Process and Messaging together
Using workflow to provide for durable and long-running services. New Tools, WF activities and new programming model classes have been added to simplify building workflow-enabled services using WF and WCF. This allows a .NET Framework developer to build business logic for a service using WF and expose messaging from that service using WCF. These improvements not only provide tools for this scenario but they reduce the amount of glue code that was previously required.
Web 2.0 Friendly and AJAX Enabled WCF Services
Ajax is a web development technique for making asynchronous exchanges of small amounts of data between browser and web service calls from the browser client script to the web server. A programming model is provided for building Ajax style web applications using WCF services. An HTTP programming model is also provided allowing for REST style web services.
Visual Studio Developer Tools for WF, WCF and in Visual Studio “Orcas”
Visual Studio”Orcas” has built in tools for web service authoring with WCF and for building workflow enabled software with WF. There are new project templates for WCF services, WF business logic, workflow enabled services, and AJAX services. The templates are conveniently set up to compile and run even before any custom code is added enabling .NET developers to get going quickly. There are also numerous other tools for developing with WF, WCF and WPF.
More WS-* Standards Support
Implementation in WCF of the latest OASIS specifications Web Services Atomic Transaction (WS-AtomicTransaction) 1.1, WS-ReliableMessaging 1.1, WS-SecureCOnversation and Web Services Coordination (WS-Coordination) 1.1.
RSS and ATOM Syndication API
Applications built using WCF will be able to easily expose syndicated data which can be consumed by an RSS or ATOM reader.
Partial Trust Support for WCF Hosting
Partial trust on the vlient is provided for ASMX parity focussing mainly on partially trusted WCF applications deployed through click-once. Support is provided for basic HTTP binding provided that the application runs in the Internet zone permissions and have granted the apropriate WebPermission. Secure communication is possible through transport security only. All other features are not available to partially trusted applications including hosting services, duplex communications, non-HTTP transports, WS-* protocols and any WF use.
Rules Data Improvements
The rules engine in WF is improved to add support for C# 3.0 extension metods, and for operator overloading . Also the ”new” operator is added to compete the base set of expression types.
Built-in WPF tools for Visual Studio “Orcas”
The Visual Studio designer for WPF was previously released as a CTP. It is not integrated into the development environment and is significantly improved.
Additional WPF Features and Improved Performance
WPF has smoother animations, faster startup and better overall performance. There are also new data types available for data binding with LINQ. Better integration support is now provided for with codename “WPF/E”.

Introduction
This application demonstrates how to send mail with attachments using SMTP server and how to configure the default SMTP server. The System.Web.Mail namespace provides classes for sending email in .NET. The classes involved are MailMessage which manages the content of the mail message and MailAttachment which manages the mail attachments.
Setting SMTP server
Before running the application you need to confirm these server settings:
- Make sure that the SMTP server is running, only then it can relay mail. If not, open the IIS window, in IIS look for the "local computer" on the left side tree view under which you will see the "Default SMTP Virtual Server", if it is not available, then you need to install it.
- To configure "Default SMTP Virtual Server", right-click on it, go into "Properties", and select "Access" tab, and then click the "Relay" button. With "only the list below" radio button selected, you should see the local IP address: "127.0.0.1", if it's not there, you need to add it.
- If you are using "localhost" or "127.0.0.1" as the
SmtpMail.SmtpServer, make sure "Anonymous access is allowed". To allow access, open up the IIS. Locate the SMTP virtual server, and right-click select Properties. On the Access tab, click the Authentication button. Make sure "Anonymous Access" is the only checkbox checked.
- Use real from and to addresses that exist on the
SmtpMail.SmtpServer. Do not use invalid address.
Getting objects
Initially, we need to create a new object for the MailMessage class, we will call it "mailMessage". Then we set the From, To, Cc, Bcc, Subject and Body properties as well as the BodyFormat of this object to the values on our web form:
MailMessage mailMessage = new MailMessage ();
mailMessage.From = txtSender.Text;
mailMessage.To = txtReceiver.Text;
mailMessage.Cc = txtCc.Text;
mailMessage.Bcc = txtBcc.Text;
mailMessage.Subject = txtSubject.Text;
mailMessage.Body = txtBody.Text;
if (rblMailFormat.SelectedItem.Text == "Text")
mailMessage.BodyFormat = MailFormat.Text;
else
mailMessage.BodyFormat = MailFormat.Html;
Making attachments
To make attachments we need to use the MailAttachment class and for this we create an object attach. The following block of code checks the Open File Dialogs of our web form (the Open File Dialog is an HTML file field control to which we've added the runat="server" property). If there is a value, the file is uploaded, saved on the server and added as an attachment to the email.
if (inpAttachment1.PostedFile != null)
{
HttpPostedFile attFile = inpAttachment1.PostedFile;
int attachFileLength = attFile.ContentLength;
if (attachFileLength > 0)
{
strFileName = Path.GetFileName(inpAttachment1.PostedFile.FileName);
inpAttachment1.PostedFile.SaveAs(Server.MapPath(strFileName));
MailAttachment attach = new MailAttachment(Server.MapPath(strFileName));
mailMessage.Attachments.Add(attach);
attach1 = strFileName;
}
}
Now, we send the email with the attachments:
SmtpMail.SmtpServer = "127.0.0.1";
(Or)
SmtpMail.SmtpServer.Insert(0,"127.0.0.1");
SmtpMail.Send (mailMessage);
Finally, if the attachments are available then we need to delete it:
if (attach1 != null)
File.Delete(Server.MapPath(attach1));
if (attach2 != null)
File.Delete(Server.MapPath(attach2));
if (attach3 != null)
File.Delete(Server.MapPath(attach3));
Various ways to set the SMTP Mail server:
SmtpMail.SmtpServer = "localhost"
or
SmtpMail.SmtpServer = "127.0.0.1"
or
SmtpMail.SmtpServer.Insert( 0,
"127.0.0.1 or your mail server name here")
You need to replace "localhost" with the name or IP address of your SMTP Mail server on a Windows desktop computer or you can insert the server but "localhost" is the default value and it usually works.