473,386 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

LinqToSQL CancelUpdate

I'm writing an application using LinqToSQL. Basically the application
works as follows:
- Read a file
- Add rows to the database (the rows belong to more than one table).
- Call DataContext.SubmitChanges() to presis those rows into the
database.

It might be possible that there are problems in the datal. In this
case, the rows donīt need to be inserted into the database. So I donīt
call SubmitChanges. However, this scenario causes serious issues.
Since there is no CancelUpdate, LINQ to SQL will attempt to add the
data from the earlier attempt, which probably is corrupt. The only way
to recover is to restart the application!

I really like the transaction idea of Linq: make a lot of changes and
Linq applies them in batch. However, as far as I know there is no way
to cancel these changes, which is a huge drawback. Am I overlooking
something? Is there some way to cancel the pending changes? Or do I
need to keep track of each and every object I either modify or insert
and revert the changes myself?

Any pointers would be greatly appreciated!
Kind regards,
Bram Fokke
Jan 8 '08 #1
1 2023
If you don't call SubmitChanges() there is no update, so we are good on the
DB level.
To handle your linq objects, just dispose the old DC and create a new one is
the easiest way.
If this "error" is the exceptional case, this method should be fine.

W

"Bram" <b.*****@gmail.comwrote in message
news:96**********************************@e25g2000 prg.googlegroups.com...
I'm writing an application using LinqToSQL. Basically the application
works as follows:
- Read a file
- Add rows to the database (the rows belong to more than one table).
- Call DataContext.SubmitChanges() to presis those rows into the
database.

It might be possible that there are problems in the datal. In this
case, the rows donīt need to be inserted into the database. So I donīt
call SubmitChanges. However, this scenario causes serious issues.
Since there is no CancelUpdate, LINQ to SQL will attempt to add the
data from the earlier attempt, which probably is corrupt. The only way
to recover is to restart the application!

I really like the transaction idea of Linq: make a lot of changes and
Linq applies them in batch. However, as far as I know there is no way
to cancel these changes, which is a huge drawback. Am I overlooking
something? Is there some way to cancel the pending changes? Or do I
need to keep track of each and every object I either modify or insert
and revert the changes myself?

Any pointers would be greatly appreciated!
Kind regards,
Bram Fokke

Jan 8 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: JSMiami | last post by:
I have a form that has the navigation buttons enabled. I have a procedure that runs every time a new record is loaded (Current Event). This procedure performs a SELECT from a table (different from...
2
by: NewDBGirl | last post by:
I have a multiple-page form for entering info about a project with several sub-forms for sub-projects, notes and tasks. The form and one of the sub-forms each have a combo box to select a record...
0
by: crispywafers | last post by:
Hi, Hope someone can help me out. I have a piece of code I use to update a subforms numbers (Trimester Invoices) if the mainform numbers (School Year Order) change. What is interesting is the...
1
by: Gary | last post by:
I have two subforms on this on main form. One subform contains relevant contact data for respective building jobs and the other subform contains pictures of the particular record. when using the...
7
by: Nitramiir | last post by:
I have encountered a problem which I'm still trying to fix. I'm ADO recordset to communicate with front end (form with textboxes) and main access table. It is as follows; Setup ado recordset ...
9
bhcob1
by: bhcob1 | last post by:
Hey guys, 'Update or CancelUpdate without AddNew or Edit' On my database i keep occasionly get this error when i try and edit a field, it is not everytime. It will be working fine and then this...
9
anastasius
by: anastasius | last post by:
I have read other posts with a similar problem but I have not read of one like this. When a user selects a name from the drop-down list called "cboLastName" (which is unbound and whose...
0
by: d-42 | last post by:
You wrote a great deal and there is so much I would have liked to elaborate on but this really de-railed the whole debate. You posted that linq DOES throw an exception if its not ordered, and that...
1
by: =?Utf-8?B?S2ltIFM=?= | last post by:
In my professional work I work with SQL server express and VS 2008 Pro and re I know how to connect LinqtoSql. But then I work on my own computer with SQL server express and VS 2008 express its...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.