LINQ in Action roller

LINQ to SQL: How to create non-database bound objects?

I have tables: Sport ID (PK) Name Team ID (PK) SportID (FK) Name The database mappings are created with the Orcas Beta 1 LINQ to SQL Designer. Sample code: var sportList = from s in dc.Sports where s.ID == 1 select s; Sport sport = sportList.First(); Team team1 = new Team(); team1.Sport = sport; team1.Name = "foo1"; Team team2 = new Team(); team2.Sport = sport; team2.Name = "foo2"; dc.Teams.Add(team2); dc.SubmitChanges(); // This throws NullReferenceException because team foo1 Read More...
Published Tuesday, May 22, 2007 11:19 AM by MSDN Forums: LINQ Project General
Anonymous comments are disabled

Featured Item

This Blog

Sponsoring

Syndication