SilverLight LINQ Integration

Linq queries are used to filtering the data and formatting the data.

The Microsoft introduced linq concept in the 3.0 .net framework, the linq queries designed based on anonymous variables and generic classes

As per .net technologies ‘var’ is anonymous data type, in the anonymous variables we can maintain value format data and reference format data.

The linq queries we can inhelit to the ‘object,’ ‘ADO . net’ and “XML”

Example on Silverlight linq Integration

(Retaining greater than 5 array elements from the arraylist)

Open new silverlight application

  • Add list box and button control
  • Go to button click event

Private void button :- click (object sender, routed Event agrs e)

{

Int [] a = {1,5,8,3,6,9,4,22,25,2,7};

Var x = from I in a where  i> 5 select I ;

For each (var v in x)

{

List box1. Items. Add (v. tostring ());

}

}

Formatting string array elements

Open new silverlight application

Add listbox and button control

Go to button click event

Private void button 1_click (object sender, routed event arge e)

{

String [] x = { “asd”, “zkd”, “poi”, “aad”, “tyu”, “klm:};

Var str = from I in x order by I as ceding select I ;

Foreach (var v in str)

{list box 1.items add (v.to string ());

}

}