Dapper-Extensions
Dapper-Extensions copied to clipboard
Async/Await methods do not appear to use DapperExtensions.DapperExtensions.SetMappingAssemblies
If I have a custom mapping that is not in the same assembly, I cannot use DapperExtensions.DapperExtensions.SetMappingAssemblies to set the correct assembly to search. It gives me the error "SqlException: Invalid object name 'CMSContent'." The code to reproduce this is:
// Works as expected
static void GetData()
{
DapperExtensions.DapperExtensions.SetMappingAssemblies(new[] { typeof(CMSContentMapper).Assembly });
var cn = new SqlConnection("CONNECTION STRING HERE");
cn.Open();
var y = cn.GetList<CMSContent>();
cn.Close();
}
// Throws an exception
static async Task GetDataAsync()
{
DapperExtensions.DapperExtensions.SetMappingAssemblies(new[] { typeof(CMSContentMapper).Assembly });
var cn = new SqlConnection("CONNECTION STRING HERE");
cn.Open();
var y = await cn.GetListAsync<CMSContent>();
cn.Close();
}
In another assembly, I have the following map file:
public class CMSContentMapper : ClassMapper<CMSContent>
{
public CMSContentMapper()
{
Table("CMSContents");
AutoMap();
}
}
Im on 1.50.2 of Dapper and 1.6.1 of DapperExtensions.
Do I have an error or am I misunderstanding a concept? Thanks!
I have the same issue. The async version ignores the custom class mapper, the non async one works fine.
I've run into the same issue.
Using 1.50.2 of Dapper and 1.6.3.0 of DapperExtensions.
use DapperExtensions.DapperAsyncExtensions.SetMappingAssemblies(assemblies);
For me both DapperExtensions.SetMappingAssemblies
and DapperAsyncExtensions.SetMappingAssemblies
did not work.
Is there a specific location where we should call DapperAsyncExtensions.SetMappingAssemblies
?
Any updates on this? I'm running into the issue as well. DapperAsyncExtensions.SetMappingAssemblies
is not working for me..