Skip to main content

Posts

Showing posts with the label LINQ

The Amazing LinqToXML with C#

XAttribute , XComment , XDeclaration , XDocument , XElement , XName / XNamespace Creating XML :             XElement inventory =                                     new XElement ( "Inventory",                                                 new Xelement ( "Car", new XAttribute("ID", "1"),                                      ...

Visual Studio and LinqToSql (.dbml)

Visual Studio 2008 and onward  provides LinqToSql(.dbml) Item to automatically create entities, generate classes and provides a designer to manipulate those entities classes. Inserting new Data in tables :             Inventory newCar = new Inventory();             newCar.Make = "Yugo";             newCar.Color = "Pink";             newCar.PetName = "Betty";             newCar.CarID = newCarID;             ctx . Inventories . InsertOnSubmit (newCar);             ctx . SubmitChanges() ; Updating Data :             v...

C#, LinqToSql and Entity Classes and SqlMetal.exe

What is DataContext :             Bridge that allows execution of Linq query expression on actual database. Pass you Linq expressions to DataContext to execute. Simple LinqToSql Entity: [Table] public class Inventory {             [Column]             public string Make;             [Column]             public string Color;             [Column]             public string PetName;             // Identify the primary key.             [Column(IsPrimaryKey = true)] ...