learn-Linq-step-by-step

learn-Linq-step-by-step


→ ♣ Videos are available here   http://www.asp.net/learn/linq-videos/

All 7 videos are step by step


Linq is language integrated query.
Below is simple examle of Linq syntex

We will query an array of string.

//Create an array of Strings

string[] arr = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z".Split(",".ToCharArray());

//Populate listbox with array of strings

ListBox1.DataSource = arr;

//Bind array of strings to Listbox

ListBox1.DataBind();

//Using linq syntex we will query an array of strings and find the word "S"  and "M"

var
query = from alphabet in arr

                    where (alphabet == "S" || alphabet == "M")

                    select alphabet  ; 
                   // A query body must end with a select clause or a group clause 

foreach(var alpha in query)

{

Response.Write(alpha+"<Br/>");   //Write the word found

}


 


How simple it is ! ∞

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Author

code tutorial