submitchanges

can't insert new row into a child table with submit changes in a linq to sql app

I can't figure out the correct way to insert a new record in a child table. There's a single datacontext in the app and the target table (CustNotes) is a child of a table named Customer. There's a one to many association between Customer and CustNotes. The datacontext name is CustomerOrdersDataContext. Here's the code I'm using: priva...

LINQ context SubmitChanges

Regarding the SubmitChanges order (Insert, Update, Delete), is there a way to change that order? I need to have the Deletes executed first, any updates, then any new inserts. I have a datagrid where the user can do all add, changes and updates and submit. Since each grod row must have a unique item chosen in it (via a dropdown), it's pos...

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 =...

SubmitChanges doesn't save but removes inserts from change set, no errors

I have a deeper question regarding debug functionality of Linq to Sql SubmitChanges() Function. I want to save a record in a table of a locally cached db (localdbcache: server SqlExpress 2008 client SqlCE). Before calling SubmitChanges I can find the new item via DataContext.GetChangeSet(). After calling Submit Changes, the items to ins...

Linq To Sql - DataContext.SubmitChanges() problem

I have a code like this. DBContext is Datacontext instance. try { TBLORGANISM org = new TBLORGANISM(); org.OrganismDesc = p.Subject; DBContext.TBLORGANISMs.InsertOnSubmit(org); DBContext.SubmitChanges(); } catch (Exception) {...

Exceptions by DataContext

I've been doing some searching on the internet, but I can't seem to find the awnser. What exceptions can a DataContext throw? Or to be more specific, what exceptions does the DataContext.SubmitChanges() method throw? EDIT For reference, here a List of possible known exceptions that could be thrown by the L2S DataContext: SqlException ...

Inspection of Insert Statement When Using LINQ's SubmitChanges

Hi. I want to see what my insert statement would look like as if I was wiring up an text-based ADO.NET command. How do I do this? I have been following the below link: http://damieng.com/blog/2008/07/30/linq-to-sql-log-to-debug-window-file-memory-or-multiple-writers And have added the DebugTextWriter class to my project. So, now, i...

Several SubmitChanges in succession very slow

Hi, One question: Why when I use following code for (int i = 0; i < 10000; i++) { Entity e = new Entity(); e.DisplayValue = i.ToString(); ctx.Entities.InsertOnSubmit(e); } ctx.SubmitChanges(); it finishes after about 8 seconds but when I use this code for (int i = 0; i < 10000; i++) { Entity e =...

LINQ insert related records

Hi I have a database with a "configs" table each new row in the configs table is 4 a different client which can config his environment to his liking (theme,companyname,language, culture...) one record,lets say id=-1, is the default config. all new configs should copy everything from there i want that each time i (the main admin) add a ne...

"Row Not Found or Changed" Error Pops Up Randomly

When I run DB.SubmitChanges(); I occasionally get an error that reads: "Row not found or changed". The reason why this error bugs me so much is because there will always a row that should be found for this query, and changes are only made if there are new changes to make. I can't seem to figure out why this error pops up Are there s...

LINQ to SQL context.SubmitChanges - How to get error details?

Hi! I'm working on an application where a lot of data is inserted into an SQL database at once. I use LINQ to SQL, and have something like this as my insert operation: foreach (var obj in objects) { context.InsertOnSubmit(obj); } context.SubmitChanges(); Here's the problem: If I get an exception (for instance, DuplicateKeyException),...

DataContext Conflicts with no Member conflicts

I am getting a ChangeConflictException when I try to SubmitChanges using my DataContext. The submit is attempting to do 8 updates with each update being only a single field in the record. When I catch the exception, I have looked at the .ChangeConflicts and there are 8 of them, but here's the weird thing, the .MemberConflicts of each c...

LINQ DataContext inserts object that is not attached

I have created two separate objects, one of class Order and one of class TempOrder. When I try to insert the TempOrder object in the db using db.TempOrders.InsertOnSubmit(obj) and then calling db.SubmitChanges the Order object gets submitted as well (without being attached to the datacontext or anything). There is no relationship betwe...

How often to call DataContext.SubmitChanges() for a large number of inserts?

How many InsertOnSubmit should I call before calling SubmitChanges? I'm adding data from a web service that can return tens of thousands of records one record at a time. The wrapper class around the web service exposes the records a an IEnumberable collection to hide an elaborate chunking mechanism. Are there guidelines on how many inse...

Issue with Updating Changes in LINQ

I'm having an issue with updating the database. The app shows the updated value, but the database does not. No errors returned. My table has a PK. Using DotConnect for Oracle, but the LINQ syntax is the same. namespace ConsoleApplication1 { class Program { static void Main(string[] args) { DataCon...

LINQ SubmitChanges() Behaviour

Hello, I have a Windows Form application using LINQ to SQL. It's working all good and fine but there is one thing I fail to understand. In one of the forms, I have a DataGrid which shows a list of order items. When I save them using SubmitChanges(), in the first call (after the application has been run) it saves the ALL the order item...

LINQ to SQL - How do stored procedures interact with unsubmited datacontext changes?

Someone here asked: "Linq-To-Sql enables calling SPs. If this SP executes an update/delete/insert, do I need to SubmitChanges() after it?" And the answer was: "No you don't. The code will work. Submit changes is only concerned with modified LINQ to SQL objects and not stored procs." I would just like to clarify: (Please excuse me, I...

Linq SubmitChanges() function - when to call?

When manipulating data using Linq, how often does the SubmitChanges() method have to be called? In my project, there are a few tables related with foreign keys. In the creation SQL, these foreign keys are constrained so a record that is part of a relationship can't be deleted without the dependant records being deleted first. Therefore...

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...

please help with sqlite exception

hi, I'm getting this error when the program executes mainDb.SubmitChanges(): INSERT INTO projects VALUES (@p0) SELECT CONVERT(Int, SCOPE_IDENTITY()) AS [value] -- @p0: Input String (Size = 0; Prec = 0; Scale = 0) [test2] -- Context: SqlProvider(Sql2008) Model: AttributeMetaModel Build: 3.5.30729.4926 my code has the following files: P...