Questions tagged [submitchanges]

Computes the set of modified objects to be inserted, updated, or deleted, and executes the appropriate commands to implement the changes to the database.

Computes the set of modified objects to be inserted, updated, or deleted, and executes the appropriate commands to implement the changes to the database.

Read more in: DataContext.SubmitChanges Method.

103 questions
0
votes
2 answers

how does linq2sql handle tables with just FK in it?

I have a mapping table like: Article_to_Categories ArticleID CategoryID How would I insert into this table using linq2sql?
mrblah
  • 99,669
  • 140
  • 310
  • 420
0
votes
2 answers

SubmitChanges() update only 1 field?

I'm really a LINQ newbie. I got an unknown problem: public static int save(TEntity obj) { var table = dbo.GetTable(); var mapping = dbo.Mapping.GetTable(typeof(TEntity)); var pkfield =…
Alex Do
  • 3
  • 1
0
votes
4 answers

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

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…
0
votes
1 answer

What is the best practice for committing changes using a LINQ2SQL datacontext in a Silverlight application using RIA?

I've got a Silverlight app using RIA services and LINQ2SQL and have objects in my Silverlight app. I query all the records in a table (via a LINQ query, using a datacontext) in the Silverlight app and create a user control for each object (record)…
Handleman
  • 754
  • 2
  • 10
  • 19
0
votes
1 answer

Linq: How to verify dbcontext.SubmitChanges() for updates/inserts succeeded?

How do you verify that SubmitChanges() worked for inserts and updates? The method doesn't return a bool or int value.
burnt1ce
  • 14,387
  • 33
  • 102
  • 162
0
votes
1 answer

prevent data insertion in LINQ to Data context (c#)

i want to prevent record insertion when nameTextBox and addressTextBox are null. but it always throws an exception. the exception message is pointed to submitchanges() which is use to insert the record. below is my code if…
0
votes
1 answer

DataContext.Submit and TransactionScope

Please explain me pseudocode below. My idea is: 3-nd SubmitChanges will commit o.Status and will not commit o.TransactionId, and my object will get corrupted in database (I mean it will not be consistent anymore). XDataContext DB = .....; XOrder o…
Denis
  • 3,653
  • 4
  • 30
  • 43
0
votes
0 answers

DataContext update and rollback

I'm having a problem with my DataContext. In the following code snippet, I first delete existing objects in my datacontext, and later in same code, adding new again. The problem is, since I'm using .DeleteOnSubmit() its still containing 2 entities…
grmihel
  • 784
  • 3
  • 15
  • 40
0
votes
1 answer

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…
hIpPy
  • 4,649
  • 6
  • 51
  • 65
0
votes
2 answers

LINQ to SQL How can I submit changes after closing the connection?

I am accessing a database using LINQ, and making changes to the records. I retrieve the records like so: using(var db = new DatabaseDataContext(connectionString)) { var query = from item in db.table where item.senddate == null …
Tim
  • 2,731
  • 9
  • 35
  • 72
0
votes
2 answers

AutoIncrement on SubmitChanges in RIA Services

I am using RIA Services with Entity Framework in Silverlight 5. i have a following Foo table; Fooid FooName FooCode FooRef Fooid is an auto-increment number - works like a charm on save ... FooName is set in ViewModel - works fine on save…
Thr3e
  • 358
  • 1
  • 6
  • 22
0
votes
1 answer

Silverlight DomainContext load with two separate DomainDataSources

I have a confusion regarding DataContext which i would like someone to confirm or comment please. In plain English, I believe a DataContext is a container which can be filled with entities upon load. e.g. I have two entities named Customers and…
Thr3e
  • 358
  • 1
  • 6
  • 22
-1
votes
1 answer

Linq to SQL DataContext missing SET clause on calling SubmitChanges

I am currently stumbling across some C# Linq to SQL DataContext misbehavior when retrieving a data set, changing it and invoking SubmitChanges to save the changes back to the database. I searched around and found this SO-Question pointing out…
Thomas
  • 76
  • 8
1 2 3 4 5 6
7