开发者

Mapping properties between two databases using Fluent NHibernate & S#arp Architecture

I have a scenario where I have a new application built using NHibernate and S#arp Architecture. This application is being integrated into a legacy application that does not use NHibernate. There will be separate databases for the legacy and new applications. I am able to successfully read objects from both databases using two S#arp NHiberate factory keys (as detailed here). This all works great. My problem is when I want to map a property from a class in my new application to an object in the legacy database. Consider the following scenario:

public class NewUser
{
    public virtual LegacyUser LegacyUser { get; set; }
}

public class LegacyUser
{
    public virtual string UserName { get; 开发者_运维问答set; }
}

I can read my NewUser objects, but when I attempt to reference the LegacyUser property I get an error:

System.Data.SqlClient.SqlException: Invalid object name 'NewSchema.LegacyUser'.

I suspect this is happening because the session that is retrieving the NewUser objects doesn’t know anything about the session that is required to read the old user objects. The session factory key is usually specified by the S#arp repository.

I've tried specifying the schema in the mapping, but this doesn't work either.

mapping.Schema("OldSchema");

Question: Is there any way to specify in the Fluent NHibernate mapping that when the NewUser object attempts to read the LegacyUser object it needs to use a different session factory? Or do I have to manually read the objects from the legacy database and insert them into my new classes?

Thanks in advance!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜