Replace the ConnectionString name “Local” with your database connection name SampleDataContext is a user defined class derived from SqlServerDataContext Add this code in ConfigureServices(IServiceCollection services) method in Startup.cs Option 1: Create the instance in the Web API via dependency injection. You can use the same instructions with the corresponding methods to create an instance for the other database types including Oracle, PostgreSQL, MySQL, SQLite, ODBC etc. The following code examples create an instance of DataContext for SQL Server. When a DataContext is instantiated, a database connection is automatically created and the connection is set as the DataContext's CurrentConnection. Rather, you have to instantiate a database-specific DataContext. public virtual void Rollback()ĭataContext is an abstract class, so you cannot directly instantiate a DataContext. Rollback() - Rolls back the current transaction on the context. public virtual IAdoDbTransaction BeginTransaction(IsolationLevel isolationLevel)Ĭommit() - Commits the current transaction on the context. public virtual IAdoDbTransaction BeginTransaction()īeginTransaction(IsolationLevel) - Creates a new transaction for the underlying database with the specified isolation level using the current connection on the context and makes it the current transaction. Transaction APIsīeginTransaction() - Creates a new transaction for the underlying database with the default isolation level using the current connection on the context and makes it the current transaction. NET DataStore has dependencies on the following SnapObjects NuGet packages:ĭataContext in SnapObject is the object used to manage database connections and transactions. NET DataStore explicitly and/or implicitly uses SnapObjects DataContext's transaction APIs to manage transactions, using transactions in. This document will describe how to work with transactions for CRUD operations (create, read, update and delete) in.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |