Archives de catégorie : DotNet – LINQ

DotNet – parsing & creating xml with LINQ

  File XML: <? xml version="1.0" encoding="utf-8" ?> < Customers> < Customer CustomerID="albert" ContactName="sophie pilloud" City="Geneve" /> <Customer CustomerID="Dupond" ContactName="zehnda blanc" City="Lausanne." /> <Customer CustomerID="Durand" ContactName="michael gfeller" City="Zuerich" /> </Customers>    Parsing XML Document using System; using System.Linq; using System.Xml.Linq; … Lire la suite

Publié dans DotNet - LINQ | Laisser un commentaire

DotNet C# 3.5

Collection initializers   List<int> list = new List<int>() {1,2,3};   Query expression   var query = from number in list                   where number < 3                   select number;   Here why the select clause appears on the last line of … Lire la suite

Publié dans DotNet - LINQ | Laisser un commentaire

LINQ to SQL

static void Main(string[] args) {   string connectionString = "AttachDBFileName=’" + Path.GetFullPath(Path.Combine(Application.StartupPath, @"..\..\..\..\..\Data\NORTHWND.MDF’;")) + @"Server=’.\SQLEXPRESS’;user instance=true;" + "Integrated Security=SSPI"; DataContext db = new DataContext(connectionString); // DataContext db = new DataContext(@"c:\data\northwnd.mdf"); var query = from c in db.GetTable<Customer>() where c.City == … Lire la suite

Publié dans DotNet - LINQ | Laisser un commentaire

LINQ – Langage Integrated Query

Generics List<strings> (list of strings)   A programming language mechanism by which a single piece of code (function, object, interface, etc.) can manipulate many different data types without explicitly having a separate entity for each data type   Essence   … Lire la suite

Publié dans DotNet - LINQ | Laisser un commentaire