Transactions
Transaction is a service in which, a series of actions either succeed or fail. If it fails,
all the changes made by the transaction are undone automatically. The DataContext
takes care of handing transactions. It makes use of the transaction if one is already
created, otherwise it creates one transaction on its own for all the updates that
happen through the DataContext.
LINQ to SQL is a new feature supported by ADO.NET. So LINQ to SQL should be
able to make use of other features of ADO.NET. ADO.NET uses a connection object
which takes the connection string as parameter for connecting to the database. When
we create a DataContext, we can make use of the connection created by
ADO.NET. LINQ to SQL will use the same connection for its queries and updates to
the database. For example, the ADO.NET connection to the database Deserts in the
local server will be as follows:
SqlConnection connection = new SqlConnection("PersistSecurity
Info=False;Initial Catalog=Deserts;
Integrated Security=SSPI;server=(local)");
connection.
Pages:
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202