LINQ

From Logic Wiki
Jump to: navigation, search

What Is LINQ

Linq is a different approach to query, filter, update data LINQ query variables should be one of the types derived from IEnumerable<T> like List<T>

Example 1

var sorgu = from eleman in koleksiyon
where kriterler
orderby sıralamaKıstası [ascending|descending]
select [takmaAd = ]kolonIfadesi [ , [takmaAd2 = ] kolonIfadesi2]

Standard Query Operators

string[] sehirler = { "Ankara", "İstanbul", "Aydın",  "Antalya", "İzmir", "Konya",  "Aksaray", "Kocaeli"  };
 
IEnumerable<string> sorgu = from s in sehirler
 where s.StartsWith("A") == true
 orderby s
 select s.ToUpper();
 
foreach (string i in sorgu)
{
 Console.WriteLine(i);
}

In LINQ you don't get data while you are creating query. It's a seperate process to run the query and get the data.