Dialect not applied to Async functions
I'm trying to use DapperExtensions with Oracle and while all of the non-async functions work fine when setting the OracleDialect, the Async functions do not.
Do I need to set the dialect differently with Async?
Exception:
Oracle.DataAccess.Client.OracleException: ORA-00936: missing expression
Below is set in unit of work contructor:
/// set in unit of work before repository and connection are established
DapperExtensions.DapperExtensions.SqlDialect = new OracleDialect();
Below is in the repository:
/// <summary>
/// Performs get list on provided entity type.
/// </summary>
/// <returns></returns>
public IEnumerable<T> GetList()
{
return _connection.GetList<T>();
}
/// <summary>
/// Performs get list async on provided entity type.
/// </summary>
/// <returns></returns>
public Task<IEnumerable<T>> GetListAsync()
{
return _connection.GetListAsync<T>();
}
Below is the unit test that fails:
[TestMethod]
public async Task GetEventTypeListAsync()
{
// arrange
var repo = _dapperUoW.CreateRepository<EventType>();
// act
var result = await repo.GetListAsync();
// assert
Assert.IsNotNull(result);
var record = result.First();
Assert.IsNotNull(record);
Assert.AreEqual(typeof(EventType), record.GetType());
}
Example of difference in SQL via miniprofiler (different table but same issue):
/// /// wrong dialect, this is SQL not Oracle /// SELECT [ABC].[ABC_EVENT].[ABC_EVENT_ID] AS [AbcEventId], [ABC].[ABC_EVENT].[BASE_ABC_EVENT_ID] AS [BaseAbcEventId], [ABC].[ABC_EVENT].[NAME] AS [Name], [ABC].[ABC_EVENT].[ABC_DATE] AS [AbcDate], [ABC].[ABC_EVENT].[LOCKED] AS [Locked], [ABC].[ABC_EVENT].[CREATED_BY] AS [CreatedBy], [ABC].[ABC_EVENT].[CREATED_DATE] AS [CreatedDate], [ABC].[ABC_EVENT].[MODIFIED_BY] AS [ModifiedBy], [ABC].[ABC_EVENT].[MODIFIED_DATE] AS [ModifiedDate] FROM [ABC].[ABC_EVENT] WHERE ([ABC].[ABC_EVENT].[ABC_EVENT_ID] = @AbcEventId_0)
/// /// correct dialect, oracle /// SELECT ABC.ABC_EVENT.ABC_EVENT_ID AS ABCEVENTID, ABC.ABC_EVENT.BASE_ABC_EVENT_ID AS BASEABCEVENTID, ABC.ABC_EVENT.NAME AS NAME, ABC.ABC_EVENT.ABC_DATE AS ABCDATE, ABC.ABC_EVENT.LOCKED AS LOCKED, ABC.ABC_EVENT.CREATED_BY AS CREATEDBY, ABC.ABC_EVENT.CREATED_DATE AS CREATEDDATE, ABC.ABC_EVENT.MODIFIED_BY AS MODIFIEDBY, ABC.ABC_EVENT.MODIFIED_DATE AS MODIFIEDDATE FROM ABC.ABC_EVENT WHERE (ABC.ABC_EVENT.ABC_EVENT_ID = :AbcEventId_0)
I am facing the exact same problem using PostgreSQL ;) ... It appears dialects are only respected using synchronous db communication. Any progress on this one?
Never mind, although not very pretty, I found out that the dialect should be set for asynchronous extensions as well:
// Synchronous
DapperExtensions.DapperExtensions.SqlDialect = new PostgreSqlDialect();
// Asynchronous
DapperExtensions.DapperAsyncExtensions.SqlDialect = new PostgreSqlDialect();
@loedeman you are a life saver :+1:. Thanks so much!