Looks like you are getting some entities with your select new
EditableCallout, and those are not the entities you have in the database. If you want to insert or update you should do that on the entities that you have in the db and not on your "own" classes that is a combination of values from the database entities
He is doing that, he's getting a database entity then manually mapping data from a dto to that entity.
CodeHobo
All-Star
18647 Points
2647 Posts
Re: Update DB using System.Linq.DataContext (LINQ To SQl)
Apr 16, 2012 04:13 PM|LINK
He is doing that, he's getting a database entity then manually mapping data from a dto to that entity.
EditableCallout target = One(c => c.id == callout.id); if (target != null) { target.ProductIdentifier = callout.ProductIdentifier; target.DateEnd = callout.DateEnd; target.DateStart = callout.DateStart; target.Value = callout.Value; target.IsActive = callout.IsActive; wdc.SubmitChanges(); }@drdexter33 - Does your table have a primary key?
Blog | Twitter : @Hattan