LINQ in Action roller

DefaultIfEmpty() and referencing null object.

See the comments plz. from c in Customers where c.CustomerID.StartsWith("P") join o in Orders on c.CustomerID equals o.CustomerID into sr from x in sr.DefaultIfEmpty() select new { CustomerID= c.CustomerID, OrderID = x == null ? -1 : x.OrderID, // This is OK. I thought this is the only way to safely access OrderID. Test = (int?)x.OrderID // But this works too. How does this work ok when x is null? } Read More...
Published Saturday, December 29, 2007 1:56 AM by MSDN Forums: LINQ Project General
Anonymous comments are disabled

Featured Item

This Blog

Sponsoring

Syndication