0
我有以下LINQ查詢,我想用護士姓名來填寫。不幸的是,這些存儲在一個單獨的數據庫中,因此存儲在一個單獨的DataContext中。我可以在另一個DataContext中調用另一個方法嗎?
如何從此查詢調用我的aspnetdbcontext
中的方法,該查詢使用cmodatacontext
?
這是aspnetdb的方法來獲得一個護士的名字:
internal static AspnetdbDataContext context = new AspnetdbDataContext();
public static IList WorkerList(Guid userID)
{
IList theWorkers;
using (context)
{
var workers = from user in context.tblDemographics
where user.UserID == userID
select new { user.FirstName, user.LastName, user.Phone };
theWorkers = workers.ToList();
}
return theWorkers;
}
這是奇美電子的方法,我稱之爲綁定到一個DataGridView:
public static DataTable GetAllMembers(Guid workerID)
{
DataTable dataTable;
using (context)
{
var AllEnrollees = from enrollment in context.tblCMOEnrollments
where enrollment.CMOSocialWorkerID == workerID || enrollment.CMONurseID == workerID
from supportWorker in context.tblSupportWorkers
where supportWorker.SupportWorkerID == enrollment.EconomicSupportWorkerID
select
new
{
enrollment.ADRCReferralID,
enrollment.ClientID,
enrollment.CMONurseID,
enrollment.CMOSocialWorkerID,
enrollment.DisenrollmentDate,
enrollment.DisenrollmentReasonID,
supportWorker.FirstName,
supportWorker.LastName,
supportWorker.Phone,
enrollment.EnrollmentDate
};
dataTable = AllEnrollees.CopyLinqToDataTable();
}
return dataTable;
}
如何我可以一起工作嗎?
謝謝!