LINQ in Action roller

Use of Single() method

In my application I want to check if a record exists, if it does I want to update it, if it does not then I want to create a new record. Originally I just used the Single operator as follows: ADMUser admUser = myDBContext .ADMUser.Single< ADMUser >(c => c.ADMUserId == userId); if (admUser != null) { admUser.LastRegistered = DateTime.Now; } else { admUser = new ADMUser(); : : myDBContext.ADMUser.Add(admUser); } The first line of code caused an exception when there was no record matching which Read More...
Published Friday, March 30, 2007 11:48 AM by MSDN Forums: LINQ Project General
Anonymous comments are disabled

Featured Item

This Blog

Sponsoring

Syndication