LINQ Object Identity

There are 1 entries for the tag LINQ Object Identity
Object Identity in LINQ To SQL

Avevo giĆ  accennato al concetto di Object Identity in LINQ To SQl tempo fa, ultimamente, parlando di LINQ To SQL, mi diverto a mettere in crisi chi mi ascolta mostrando questo esempio: //Read 'ALFKI' entry from Nothwind... MyDataContext db = new MyDataContext(); Customer cust = db.Customers.Where(c => c.CustomerID == "ALFKI").Single<Customer>(); Console.WriteLine("ALFKI Customer's city is:" + cust.City); //Updates ALFKI City to London string query = "UPDATE Customers SET City={0} WHERE CustomerID={1}"; int ret = db.ExecuteCommand(query, "London", "ALFKI"); Console.WriteLine("{0} record updated", ret); //Queries all customers living in London... Console.WriteLine("Geting customers in London..."); IQueryable<Customer> custInBerlin = db.Customers.Where(c => c.City == "London"); foreach (Customer c in custInBerlin) { Console.WriteLine("{0} lives in {1}",c.CustomerID, c.City); } L'output...

posted @ domenica 3 febbraio 2008 11.19 | Feedback (3)