Dapper Transaction (edit)
- Remove Oracle.ManagedDataAccess.EntityFramework 18.3.0
- Remove EntityFramework 6.x
- Add EntityFramework.ja 6.2.0 => Add EntityFramework (also) 6.2.0
- Add Oracle.ManagedDataAccess.EntityFramework 18.3.0 => Oracle.ManagedDataAccess (also) 18.3.0
- Add Swashbuckle 5.6.0
- Add Newtonsoft.Json 7.0.1
ExceptionNotFound/AspNetCoreDapperAsyncDemo (github.com)
Using Dapper Asynchronously in ASP.NET 5.0 (exceptionnotfound.net)
Entity Framework Entity Framework | Entity Framework 6 Tutorial and Documentation
Entity Framework, LINQ and Model-First for the Oracle Database (Beginner)
Entity Framework, LINQ and Model-First for the Oracle Database (Beginner)
EF Transaction
Working With Transaction in Entity Framework 6.0 (c-sharpcorner.com)
Transaction in Entity Framework 6 & Core (entityframeworktutorial.net)
c# - Entity Framework 6 transaction rollback - Stack Overflow
Dapper UoW
timschreiber/DapperUnitOfWork: Unit of Work and Repository Example for Dapper (github.com)
doanhnghiepvn/DapperUnitOfWork (github.com)
Unit Of Work
Articles Tutorials | AspNet Boilerplate
Repositories
Repository Pattern, Done Right - CodeProject
Articles Tutorials | AspNet Boilerplate
Comparing SQL Server and Oracle datatypes (mssqltips.com)
Summary
The following summarizes the datatype mappings described above:
SQL Server | Oracle |
---|---|
Exact Numerics | |
TINYINT |
NUMBER(3) |
SMALLINT |
NUMBER(5) |
INTEGER |
NUMBER(10) |
BIGINT |
NUMBER(19) |
DECIMAL(p,s) |
NUMBER(p,s) |
NUMERIC(p,s) |
NUMBER(p,s) |
SMALLMONEY |
NUMBER(10,4) |
MONEY |
NUMBER(19,4) |
Approximate Numerics | |
REAL |
BINARY_FLOAT |
FLOAT |
BINARY_DOUBLE |
Date Time | |
SMALLDATETIME |
TIMESTAMP(3) |
DATETIME |
TIMESTAMP(3) |
DATETIME2(fs) |
TIMESTAMP(fs) |
DATETIMEOFFSET(fs) |
TIMESTAMP (fs) WITH TIME ZONE |
DATETIMEOFFSET(fs) |
TIMESTAMP (fs) WITH LOCAL TIME ZONE |
Character strings | |
CHAR(x) |
CHAR(x) |
VARCHAR(x) |
ARCHAR2(x) |
VARCHAR(MAX) |
CLOB |
TEXT |
LONG |
Binary strings | |
BINARY(n) |
RAW(n) |
VARBINARY(n) |
LONG RAW |
VARBINARY(MAX) |
LONG RAW or BLOB |
IMAGE |
LONG RAW |
Binary strings | |
XML |
XMLTYPE |
BIT |
NUMBER(1) |
TIMESTAMP |
ORA_ROWSCN pseudo column |
UNIQUEIDENTIFIER |
RAW(16) |
N/A |
BFILE |
NuGet
- EntityFramework
- EntityFramework.jp
- EntityFramework.Extensions
- Install-Package Oracle.ManagedDataAccess -Version 18.3.0
- Install-Package Oracle.ManagedDataAccess.EntityFramework -Version 18.3.0
Dapper Extensions with Oracle database - @manhng
.NET Core With Oracle Database Using Dapper - @manhng
4 Common Mistakes with the Repository Pattern - Programming with Mosh
- Separate repository per domain class, like OrderRepository, ShippingRepository and ProductRepository
- Repositories that does not return the View Models/DTOs. Return only Domain Object. Mapping is not the responsibility of the repository.
- Don't write Save/Update method in repositories: A pattern that goes hand in hand with the repository pattern is the unit of work. With the unit of work, we can re-write that ugly code like this:
- orderRepository.Add(order);
- shippingRepository.Add(shipping);
- unitOfWork.Complete();
- Repositories that return IQueryable? Your repositories should return Domain Objects.
Using Entity Framework Core and Dapper in ASP.NET Core - Safe Transactions (codewithmukesh.com)
Using Dapper In ASP.NET Core Web API (c-sharpcorner.com)
Dapper and Repository Pattern in Web API | Mukesh Kumar
Dapper in ASP.NET Core with Repository Pattern - Detailed (codewithmukesh.com)
- Using Dapper and Entity Framework 6 for connecting to an Oracle database with Oracle.ManagedDataAccess
- Conversion approach for Guid values
- c# - Support both MS-SQL and Oracle - Stack Overflow
c# - How to solve Dapper - UnitOfWork Transaction Error - Stack Overflow
Dapper is a thin mapper over ADO.NET, it doesn't replace it. This means you still have to use ADO.NET, connections and transactions correctly. If you want to use to use explicit transactions, you need to pass it through the transaction parameter to Query or Execute:
using(var cn = new SqlConnection(...))
{
cn.Open();
using(var tx = cn.BeginTransaction())
{
var results1 = cn.QueryAsync<City>(sql1, transaction: tx);
var results2 = cn.QueryAsync<City>(sql2, transaction: tx);
}
}
Or you can use a TransactionScope:
using(var scope = new TransactionScope())
{
using(var cn = new SqlConnection(...))
{
cn.Open();
var results1 = cn.QueryAsync<City>(sql1);
var results2 = cn.QueryAsync<City>(sql2);
}
}