Great Ideas. Always Flowing.

We are not happy until you are happy. Client satisfaction guaranteed. Whatever your needs and requirements, we have the skills and resources for the job!

Popular Tags...


SnowCovered Top Sellers

Frustrated over the lack of customization for your user's registration fields? Dynamically setup your DNN Portal with custom registration fields, layout, questions, and other core integration options......

Ultra Video Gallery is a brother product of Ultra Media Gallery, UVG allows you to upload videos in various format and automatically encode them to flv or H264 format, you also can add videos from internet or record live videos from your webcam.

Build high performance, completely customizable data-entry forms and views driven by your DNN and external databases. New built-in tools make it a snap to quickly create data entry forms, data views, and even database tables. Plus, add your own HTML, CSS, Javascript, SQL commands, stored procedures,

The most advanced DotNetNuke shopping cart on the planet. Easy to use e-Commerce, Secure Shopping Cart Software and SEO friendly. B2C / B2B Ecommerce Sites.

One stop solution for events calendar and events registration! FREE DOWNLOAD is available now!

Recently Viewed...

To help you navigate to pages you most recently visited, select from the links below.    
Installing Microsoft SharePoint Foundation (MSF)...

How to Make LINQ Work For You in ASP.Net

How to Make LINQ Work For You in ASP.Net
For many programmers LINQ (Language Integrated Query) is the single most important innovation in .Net 3.5. It has radically altered the way programmers view and treat data.
Before LINQ was introduced .Net was quite like any other programming framework, providing a set of classes and controls that one could use to create applications with lesser difficulty and complexity. It could be compared to MFC and we wouldn't be very far off. But .Net framework 2 revolutionized the way people look at .Net and after .Net framework 3.5 it has become very hard to put .Net in the same box as any other framework, even Java.
The path to the development of LINQ was set with the introduction of generic types in framework 2. Generic Types made it possible to define a common set of operations that could work with all data and Microsoft used them to build first Lambda expressions and then an SQL like query syntax that made working with in memory data much more intuitive.
LINQ works with almost every kind of data including collections, XML, and even databases. Microsoft wanted to make LINQ as universal as possible, that's why it has emphasized the use of Generic collections and has introduced projects like Linq-To-Sql which  connects LINQ queries directly to SQL Server.
Before we dive into LINQ code, let's have a quick look at:
What LINQ can work with.
1. Linq-To-Objects > A part of .Net Framework 3 it makes LINQ a first class citizen of .Net Framework. You can use LINQ from directly within .Net to query/modify/update any collection that's implements IEnumerable<T> (all generic collections). This gives you SQL like filtering, sorting and updating capabilities with your variables right inside the language. It will work with any object that implements the IEnumerable<T> interface.
2. Linq-To-XML > It extends the System.Xml namespace to provide fresh extension methods and classes that you can use to make working with XML data easier.
3. Linq-To-SQL > Since LINQ provides a powerful set of tools for working with data collections, it is only natural that users of LINQ would like to use it with databases since there's no point in learning SQL when they already know LINQ. To gives programmers a uniform method to access all kinds of data Microsoft introduced Linq-To-Sql which lets you work with a SQL Server database as if it was an in-memory variable. Of course, now Linq-To-Sql is not the only interface to databases.
Many other database frameworks like Entity Framework, NHibernate, ADO.Net and others have support for LINQ queries. Third party LINQ providers have brought LINQ queries to every leading database format. Some like NHibernate are free, while others are sold as components.
How does LINQ work
I've already said earlier that LINQ wasn't a stand-alone effort. It is built upon some important feature additions in .Net framework: extension methods, lambda expressions and expression trees.
Extension methods lets a programmer extend the functionality of any class (sealed or otherwise) by adding static methods that work on the class object.
Lambda Expressions are a compact way to create anonymous functions. Many LINQ functions accept Lambda functions are arguments for filtering and selection queries. If you are new to Lambda, you'll find the syntax a bit queer and it will take a little getting used to. Here's a sample Lambda expression:
mydelegate multi = (x, y) => x * y;
This simple Lambda expression creates an anonymous function which takes two parameters and multiplies them.
The Lambda expressions are used to create Expression trees which are the soul of LINQ. Think of Expression Trees as a way to store C# code as data. This function-data is re-compiled (or interpreted if you like) to code which can be run on the collection you've sent to LINQ.
Though the LINQ query syntax is much more verbose than Lambda expressions, they are converted into Lambda expressions by the compiler.
Enough of background theory already! Let's see some real-world practical application of LINQ.
ASP.Net utilizes the full language features of .Net so you can put LINQ to good use in your ASP.Net projects. Using LINQ you can work with your .Net collections to filter and sort data effectively. Let's look at a sample query:
        struct Contact
            public string Name;
            public string Phone;
            public string Age;
            public string ID;
        public List<Contact> FilterContactsByName(string filter)
            List<Contact> contacts = GetMyContacts();
            var res = from cn in contacts
                      where cn.Name.StartsWith(filter)
                      select cn;
            return res.ToList<Contact>();
We have created a struct Contact with the fields -- Name, Phone, Age and ID. The function FilterContactsByName gets all the contacts that start with the characters in the argument ex. 'ad' will bring all people that have names beginning with 'ad' like Adrienne.
Notice that the LINQ query looks very much like a SQL query, but the select is at the end instead of the beginning. All LINQ queries begin with from. The first variable cn is a temporary variable that we will use to specify LINQ conditions against. Think of it like the temporary variable in a C# foreach loop.
The next clause is 'where'. Where is used to specify any filtering conditions that we may have. If you want, you can have simple queries without where. In the where clause we are using the 'StartsWith' extension method on the Name property of cn to find out if the name starts with certain characters.
The third part -- select is used to return all elements that match the where condition.
 Notice that the variable that holds the result is of type 'var'. Here's another new concept of .Net Framework 3.5 which is important to LINQ -- type inference.
Using type inference a variable needn't be declared with any specific type in mind. Instead it implicitly takes the type of the object that results from the operation. So you can say that type inference passes the type information along with the data which is a very powerful technique and it frees you up to retrieve data flexibly without worrying about the data type.
Custom Types
Since the type of the data retrieved is inferred (var is not a variant or an object), there is full intellisense support and you can run all data operators on it. The variable frees you up to retrieve data of any type. We could even return a custom type created on the fly using object initialization. Here's an example:
            var res = from cn in contacts
                      where cn.Name.StartsWith(filter)
                      select new { cn.Name, cn.Age };
In this example we are only retrieving the age and the name in a custom type, the variable res will still have intellisense support.
Aggregate Functions
Since the LINQ query syntax is based on SQL it aims to provide as many features of SQL that it can. Aggregate functions like Count, Sum, Average, Max, Min etc., are fully supported in LINQ. So if you want to get any aggregation information from the dataset you can do so easily. Check out this example:
            var res = (from cn in contacts
                      where cn.Name.StartsWith(filter)
                      select cn).Count();
This will return the count of all items that begin with the letters we've passed.
LINQ Query Operators
LINQ supports most of the common query operators supported by SQL, like:
SELECT - Select a result set.
OrderBy - Sort the result set.
Take(n) - Limit the result set to the specified row-count.
Skip(n) - Skip n records before selecting. Can be used together with Take to implement paging.
GroupBy - Grouping the resultset on a criteria.
Here's a slightly complex query which makes use of some of these functions.
            var res2 = (from cn in contacts
                        orderby cn.Name
                        select cn).GroupBy(cn => cn.Age).Skip(2).Take(100);
As you can see some of the query operators can be used in the query syntax, while others must be used as extension methods.
In this particular query we are selecting all contacts grouped by age and sorted by name; we are also using Skip and Take to start selection after the first 2 records and select only the subsequent 100.
Joins in LINQ
Joining two result-set is a very fundamental and important task while working with databases. LINQ makes that possible too, and not just with databases but with any in-memory collection that implements IEnumerable. Here's an example join in LINQ:
        public struct Contact
            public string Name;
            public string Phone;
            public int Age;
            public int ID;
        public struct EmailRecord
            public DateTime Created;
            public string Text;
            public int contactID;
       var res3 = from cn in contacts
                       join eml in emails on
                       cn.ID equals eml.contactID
                       select new { cn.Name, eml.Text };
This example has a simple join between two tables . We are retrieving email text sent by a user. Notice that we are using the 'equals' LINQ operator and not '==' to compare the equality of the values.
With the introduction of LINQ Data is a first class citizen of the programming language and you don't have to go through special components to work with it. LINQ is quite comprehensive and can be used to connect to database or non-database sources easily.
While LINQ depends on relatively complex concepts like Expression trees and Lambda expressions to work, their knowledge is not a requirement for you to use LINQ in your projects. The LINQ Query syntax is easy to learn and very intuitive. You can use the Query syntax to work with your data without worrying about what Lambda function it gets translated to.



Share the page?

How to Make LINQ Work For You in ASP.Net - share this page - email email - - digg digg - reddit reddit

Feedback Comments


SharePoint Web Parts

All Data Springs Web Parts Support WSS 3.0, SharePoint 2007, and SharePoint 2010 Frameworks

Please select license option for each web part you wish to purchase. We highly recommend the SharePoint Bundle to get all Data Springs Web Parts for maximum value!




Data Springs Sharepoint Bundle

Best Value! The Bundle gives you all 5 web parts in one package at a very attractive price! Best Value! We think you will be very happy with the SharePoint bundle and great price discounts you will receive. With your purchase all of the web parts below will be included.

Random Image Web Part

With Random Image for Sharepoint 2007, you can select multiple images to display randomly when the web part loads...

Stock Quote Web Part

Giving your site visitors relevant information is critical. With the Data Springs Stock Web Part you can provide your users with up to date financial information

Dynamic Image Rotator Web Part

Who would have thought? Adobe Flash® with Sharepoint! The FIRST and ONLY image rotation web part for Sharepoint using Flash Technology from Adobe! The Dynamic Image Rotator displays selected images and then rotates between the images. Several extended and optional features allow you to select the time to rotate each image, fade between

SharePoint Charts Web Part

The MOSS Chart Web Part is a web part built by Data Springs for the purpose of rendering several chart types based on data from a SharePoint list on a MOSS 2007 or WSS 3.0 Site

Dynamic News Ticker Web Part

Provide current news items with a user-friendly news ticker for your Sharepoint Portal. With millions of web sites offering information you need a fun way to display information and the solution is Flash News Ticker....

Tailored Text Web Part

 Tailored Text Web Part allows you to add text/html to your web site that can be different for anonymous users, registered users,  and even individual users specifically.


Dynamic Views Web Part

Dynamic Views is an excellent tool to:
Personalization allows you to go the extra mile in communicating or connecting one to one with your clients. When it comes to technology and web site content, you now have the power to leverage this personalization directly with your users on your DotNetNuke® site


Dynamic Login Web Part

Your site content isn't vanilla, so why is your portal's login?

Add pizazz and functionality with Dynamic Login! Use custom templates, localization, redirection rules for various roles and many more features!

DNN Modules

DotNetNuke Modules

Data Springs offers cost-saving packages that fit your needs:

Purchase the Collection 6.0

Data Springs Collection 6.0

An entire tool chest to quickly build websites and construct complex, powerful, and relevant workflow. Elevate your design with custom registration, forms, displays, reports, user management, payments, Google maps,, SQL updates, and so much more!

Best Value!  Includes all DotNetNuke modules by Data Springs.

$ 495.00

Data Springs User Management Suite 3.0

All the tools you need to enhance user & profile management from A to Z!.  A comprehensive package with 5 feature-packed modules that offer extensive admin controls and easy user interface geared towards an effective and growth-oriented site!  .... more


Includes:  Dynamic Registration     Dynamic Login   ♦   Interactive User Import     Dynamic User Directory   ♦   Renewal Reminder    A value of more than $630.00!

 $ 369.00



Check out all our individual modules!


 View Dynamic Registration

Dynamic Registration 5.0 (new release on 6/12/2013)

Need custom fields and workflow for your registration? Get all the power and ease of use to create the registration and profile management just the way you want it... more

$ 199.00

View Dynamic Forms

Dynamic Forms 4.1 (released 5/16/2012)

Whether it's for marketing, sales, contact forms, scheduling, information requests, surveys, or to simply better understand your customer needs, the possibilities for creating powerfully effective forms are now easy and endless! ... more

$ 195.00


Dynamic Views 3.1 (new on 2/7/2013)

Now have an easy yet feature-rich reporting module with custom defined display templates and unlimited search options from  Dynamic Forms or any data source like a table, view or custom query!  ... more

$ 169.00

 View Dynamic Login Module

Dynamic Login 4.1 (released 10/19/2011)

Add pizazz and functionality to your site login! Dynamic Login gives you custom templates, localization, redirection rules, SQL Validation, and Single SignOn. Want more? How about Facebook Connect, LinkedIN, and Twitter, too? Your login has never been so exciting!.   ... more

$ 149.00

 View Interactive User Import

Interactive User Import 3.0 (released 8/17/2011)

Interactive User Import provides you with the functionality to easily and quickly import users into DotNetNuke and Dynamic Registration, through a streamlined and well-documented wizard that includes many advanced features... more

$ 149.00

 View Dynamic User Directory

Dynamic User Directory 4.1 (released 4/26/2012)

The perfect compliment for extending your portals users and community! An essential ingredient for managing dynamic user information, is being able to sort key fields and create useful user directories and custom report information... more

$ 179.00

 View Renewal Reminder

Renewal Reminder 1.3

Renewal Reminder provides you with the functionality to setup email notifications for users that their security role will soon expire. After installing your renewal / security role reminder module you can now setup scheduled notifications to be distributed to your users... more

$ 129.99
 View Opt In Email

Opt In Email 5.0 (new on 4/17/2013)

'Relationship Building' and 'Communication' are two essential nuts and bolts for a business to prosper. This module allows you to bridge both of these and easily generate continuous awareness of your web site, products and services. Your prospects and customers will greatly appreciate this feature... more

$ 179.00

 View Tailored Text

Tailored Text 3.0

Personalization allows you to go the extra mile in communicating or connecting one to one with your clients. Leverage the power personalized content on your DotNetNuke site... more

$ 109.99
 View Stock Quote

Stock Quote 1.2

Giving your site visitors relevant information is critical. With the Data Springs Stock Module you can provide your users with up to date financial information... more

$ 109.99
 View Presentation Archive

Presentation Archive 2.0

With so much content on your web site, its important to give users an easy method for finding and retrieving content. Presentation Archive allows you to categorize, organize and present content within your DotNetNuke site for presentations, educational material, videos, and almost any document... more

$ 124.99
 View Real Estate

Real Estate 2.3

Real Estate 2.3 is a feature rich and user-friendly module that allows your portal users the ability to create real estate listings on your site... more

$ 149.99
 View Dynamic Image Rotator

Dynamic Image Rotator 3.3

Dynamic Image Rotator displays selected images and then rotates between the images using the Adobe® Flash® platform.  Several extended and optional features allow you to select the time to rotate each image, fade between images, and also display the images in either sequental or random order... more

 View Info Pics Gallery

Info Pics Gallery

The Info Pics Gallery Module allows you to display thumbnail pictures with information to the user about each picture, along with a detailed description regarding the set of pictures and several other optional links... more

 $ 69.99
 View Testimonials Module


The Testimonials Module allows you to display customer testimonials on your site, as well as an easy method for users to submit testimonials about your web site, services, or products... more

 $ 49.99
 View Dynamic Info Cube

Dynamic Info Cube

Take your web site out of the box! Looking for a creative and interesting way to showcase information and content on your site? With millions of web sites offering information you need a fun way to display information and the solution is Dynamic Info Cube... more

$ 99.95
 Search Engine Optimization Cloud Module for DotNetNuke

Dynamic Tags

Nearly every web site developer would agree that search engine optimization is one of key aspects to a successful web site. Part of search engine optimization requires providing search engines that crawl your web site with appropriate and meaningful content... more

$ 69.99
 View Page Tags

Page Tags

'Page Tags' pulls in search terms that users searched to find the current page. There are many benefits to displaying these search words that delivered the user to the site, find our more details ... more

$ 59.99
 Random Rounded Images

Random Rounded Images

Random Rounded Images is an easy to use upgraded version of the images module included with DNN. With RRI, you can select multiple images to display randomly when the module loads. For example, you can add 10 images to the module, and each time you refresh or load the page one of those images will... more

$ 49.99
 View Back on Track

Back on Track

Giving your site visitors fast access to areas of interest is vital to your web site's ease of use and ultimately - sales potential... more

$ 99.99

Dynamic News Ticker 2.0

Dynamic News Ticker allows you to scroll through news items in a horizontal or veritical direction with administrative features that allow you to easily customize the look of your news ticker. Each instance of Dynamic News Ticker can be set up to have different sizes, scroll directions, scroll speed... more

$ 39.00
 View Quick Poll

Quick Poll

Give your users a voice, while also providing an important way for you to gather opinions from your users and measure visitors' responses to questions on your site! Polls are significant because they can provide a way for your web site visitors to share ideas and vote on topics of your choosing... more

$ 39.99
 View Flash Contacts

Dynamic Contacts 2.0

Dynamic Contacts is the fastest and easiest way you can help visitors of your website connect with your key personnel... more

$ 79.99




Join our mailing list...

Get current news and events the easy way
Subscribe Me

Recent Blogs...

Copyright 2005 - 2011 by Data Springs, Inc.
  • film izle
  • 720 izle
  • film
  • sinema izle
  • film makinesi
  • T�rk�e dublaj film
  • film izle
  • film izle
  • baglan film izle
  • sinema izle
  • 1080 film izle
  • film mercegi