私は、Steve SandersonのPro Asp .Net MVCフレームワークに基づいて、その書籍のSports Storeアプリに記載されているようなデータモデリングを使用するアプリケーションを書いています。私のアプリはうまく動作しますが、私はCastleプロジェクトをIOCとして使用しますが、私は2つのデータベースを持っています。最初のものは、多くの種類のデータとクライアント情報を格納しています。第2のものは、各クライアントの医療データのみを記憶する。私は、データベース1とデータベース2以下1つの単一ドメインモデルのMVC複数のデータベース
に保存されている各クライアントの医療情報に位置、クライアントテーブル内のデータを返すクラスを作成する必要があります私のコードです:web.configファイルの
私のconnectionStrings:
これは私のコンクリートとのインターフェースがドメインモデルからであるnamespace DomainModel.Entities
{
public class ImprimePeriodoPaciente
{
public int CodConsulta { get; set; }
public DateTime DataConsulta { get; set; }
public string Evolucao { get; set; }
public int CodProfissional1 { get; set; }
public int CodPaciente1 { get; set; }
public string NomeProfissional { get; set; } //receives data from other db
public string NomePaciente { get; set; } //receives data from other db
public int CodProcedimento { get; set; }
public bool TagConsulta { get; set; }
public int? TagConsulta2 { get; set; }
public DateTime di { get; set; }
public DateTime df { get; set; }
}
}
:
<add name="CNRConnectionString" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=CNR;Persist Security Info=True;User ID=sa;[email protected]#@@@!" providerName="System.Data.SqlClient"/>
<add name="CNRpeConnectionString" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=pe;Persist Security Info=True;User ID=sa;[email protected]#@@@!" providerName="System.Data.SqlClient"/>
私の新しいクラス(データだけ、ないテーブルたっ)
public class SqlConsultasRepository:IConsultasRepository
{
private Table<Consulta> consultasTabela;
private Table<TEvolucao> tEvolucaoTabela;
private Table<Paciente> pacientesTabela;
private Table<Funcionario> funcionariosTabela;
public SqlConsultasRepository(string connectionString)
{
consultasTabela = (new DataContext(connectionString)).GetTable<Consulta>();
tEvolucaoTabela = (new DataContext(connectionString)).GetTable<TEvolucao>();
pacientesTabela = (new DataContext(connectionString)).GetTable<Paciente>();
funcionariosTabela = (new DataContext(connectionString)).GetTable<Funcionario>();
}
public IQueryable<ImprimePeriodoPaciente> Prontuarios {
get
{
return
(
from c in consultasTabela
join p in pacientesTabela on c.CodPaciente1 equals p.CodigoPaciente //my doom
join f in funcionariosTabela on c.CodProfissional1 equals f.CodigoFuncionario //my doom
select new ImprimePeriodoPaciente
{
CodConsulta=c.CodConsulta,
DataConsulta=c.DataConsulta,
Evolucao=c.Evolucao,
NomeProfissional= f.NomeFuncionario, //my doom
NomePaciente=p.NomePaciente, //my doom
CodProfissional1=c.CodProfissional1,
CodPaciente1 = c.CodPaciente1
}
);
}
}
コードは、このテーブルは、変数をのConnectionStringで指定された現在のデータベースに含まれていないので、私は他のデータベースへのConnectionStringの参照を作成する必要が....問題が発生した場所を示すために、「私の運命」でマークされています。データが同じdatacontext(またはそれのようなもの)からではないというエラーが表示されています。
お手伝いできますか?
私はPro Asp.Net MVC 3を読みました。私はSports Storeアプリケーションの例から遠ざかることを推奨します。私の人生でこれまでに見たことのない最も狂った、病理学的に設計された、非現実的なコードです。 Steve Sandersonはフレームワークと書籍を書いていますが、これらは実際のアプリケーションではなく、すべての例が一緒にくっついていない場合は、 大きな問題ではありません。 –
さて、彼の生活様式は厳しいようですが、私のアプリを再編成する時間はないと思っています。この時間はありません...あなたのアドバイスのためにTnx ....次のアプリが勝ちましたこのようにしてください。 – Bodyslicer