insertonsubmit

DLINQ- Entities being inserted without .InsertOnSubmit(...)?!

Hello, I ran into an interesting problem while using DLINQ. When I instantiate an entity, calling .SubmitChanges() on the DataContext will insert a new row into the database - without having ever called .Insert[All]OnSubmit(...). //Code sample: Data.NetServices _netServices = new Data.NetServices(_connString); Data.ProductOption[] te...

issue with submitChanges() inserting unwanted records in linq

I am using LINQ to insert records in the database. I create these records and keep track of them using a List. Based on some logic, I delete some of the records by deleting from the List. (I am using the same DataContext object). When I want to insert the records in the database, I do the corresponding linq table's InsertOnSubmit() fol...

LINQ to SQL: Read entity while calling "SubmitChanges" causes DuplicateKeyException

Hi, I'm experiencing a strange behavior that I really don't know how to work around it. I'm trying to read an entity just after it has been inserted (right after the ExecuteDynamicInsert) and when the partial method returns, I always get a System.Data.Linq.DuplicateKeyException "The database generated a key that is already in use.". H...

LinqToSql - "insert on submit"

hi I'm trying to insert a row in to one of my tables, so I look over the web to find an example for using the DATACONTEXT and found this one: protected void buttonSave_Click(object sender, EventArgs e) { using (NorthwindDataContext context = new NorthwindDataContext()) { Customer customer = new Customer { CustomerID =...

Linq to SQL: How to get values added thru InsertOnSubmit but before SubmitChanges?

Hi, Having trouble getting this. I need get the values that I have added to a table entity through the InsertOnSubmit method. However I have not yet invoked SubmitChanges on the table. So, I have this in a loop: mdmDC.tblMDMListItems.InsertOnSubmit(listItemsTable); But I'd like to query mdmDC.tblMDMListItems for some values entered so...

NullReferenceException when doing InsertOnSubmit in LINQ to SQL

In my database I have a table called StaffMembers when I bring this into my .net Project as through linq-to-sql an entity class StaffMember is created Now I have also created a partial class StaffMember in my project also, to add extra properties that I use in other top layers. eg. IsDeleted property. This partial class also inherits a...

In which layer to make linq-sql calls as SubmitChanges(), InsertOnSubmit() etc.

Which layer is the best layer to make linq-sql calls as SubmitChanges(), InsertOnSubmit() etc. For example, let's say I have two tables Parent and Child. Child table has foreign key on parent (Child table has ParentId column). I want to insert parent object and child objects into the db. Using linq-sql, I can do this. Parent parent =...

[LINQ]InsertOnSubmit NullReferenceException

Hello, I have a rather annoying issue with LinqToSql. I have created a class that is derived from the class in the DataContext. The problem is that as soon as I use "InsertOnSubmit(this);" on this derived class I get a NullReferenceException. I've seen some people with the same issue. However they've used a custom constructor and so...

Getting A LINQ .InsertOnSubmit To Work

Hi SO, I'm trying to get an insert to work using LINQ and am having some difficulties. I am using this example to base my code: http://msdn.microsoft.com/en-us/library/bb763516.aspx I have my data object set up, but don't know what's going on when db.Orders.InsertOnSubmit is executed. How can I create this db object to insert a dat...

Linq to SQL InsertOnSubmit for multiple objects

I have a problem with Linq to SQL InsertOnSubmit, which only seems to work for the first item in a table. For example with the following: var noteDetail1 = new NoteDetail() { Title = "Test Note Title 1", NoteText = "Test note" }; var waiverDetail1 = new WaiverDetail() { Title = "Test Waiver Title 1", NoteText = "Test waiver details tex...