I'm using DapperExtensions v4.0.30319 and I'm trying to let Dapper.Contrib know that my schema is not DBO. I have provided:
public class EngineMapper : ClassMapper<Engine>
{
public EngineMapper() : base()
{
Schema("vehicles");
}
}
I understand from the DapperExtensions documentation (https://github.com/tmsmith/Dapper-Extensions/wiki/Customized-mapping-for-a-class) that this class will be automatically found using reflection?
But I also tried explicitly using:
DapperExtensions.DapperExtensions.DefaultMapper = typeof(EngineMapper);
Either way when I use Dapper.Contrib's:
SqlConnection.Insert(new Engine());
the resulting insert statement does not specify any schema.
How do I do an insert (or update, etc) using Dapper.Contrib where it uses the table schema which I specify?
You can use Table
attribute to show schema
and table
name together with a dot in between:
using Dapper.Contrib.Extensions;
[Table ("vehicles.YourTables")]
public class YourClass
{
public int Id { get; set; }
public string Name { get; set; }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With