Dapper扩展更改架构 [英] Dapper Extensions Change Schema
本文介绍了Dapper扩展更改架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Dapper Extensions对数据库执行一些简单的CRUD操作。我的问题是我使用的表与dbo处于不同的架构中。有没有办法在dapper扩展级别上选择模式?
I am using Dapper Extensions to do some simple CRUD operations on a DB. My problem is that the tables I am using are held in a different schema to dbo. Is there a way to choose the schema at the dapper extensions level?
或
这应该解决吗?
推荐答案
您可以使用AutoClassMapper将新的模式分配给您的模型。有关此内容的概述,请参见扩展站点。基本上,您将需要为每个具有不同架构的模型创建一个AutoClassMapper。声明它的最佳位置是模型本身,例如:
You can use the AutoClassMapper to assign a new schema to your model. An overview on this is on the extensions site. You will basically need to create an AutoClassMapper per model with a different schema. The best place to declare it is alongside your model itself like:
public class MyModel
{
public Guid Id { get; set; }
}
public class MyModelMapper : AutoClassMapper<MyModel>
{
public MyModelMapper() : base()
{
Schema("YourNewSchema");
}
}
这篇关于Dapper扩展更改架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文