开发者

Changing the Nhibernate entity to point to new table

开发者 https://www.devze.com 2023-04-08 06:20 出处:网络
I am using FLH and recently I changed the name of the table. I dont want to propagate the changes all the way across my layers. Is there a way, where I can retain the same entity name and just change

I am using FLH and recently I changed the name of the table. I dont want to propagate the changes all the way across my layers. Is there a way, where I can retain the same entity name and just change the mapping. For example, my current entity name is Issuer and the table name is also issuer. However, the table name is changed to "counterparty" and I want to retain the entity name as Issuer. How can I achieve this?

I found the answer for the above problem. I made use of IAutomappingOverride interface. The sample code is below

public class IssuerMap :开发者_运维知识库 IAutoMappingOverride<Issuer>
{
    public void Override(AutoMapping<Issuer> mapping)
    {
        mapping.Table("Counterparty");
    }
 }

Also found some related links Fluent Nhibernate - How to specify table name


You would need to have a Table("Counterparty") clause in your classmap, as in How to specify table name in Fluent NHibernate ClassMap class?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号