I have the below LINQ Query that I would like to suppliment with the Nurse Names. Unfortunately these are stored in a seperate DB and thus a seperate DataContext.
How would I go about calling a method in my aspnetdbcontext
from this query, which uses cmodatacontext
?
This is the method in aspnetdb to get a nurse's name:
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;
}
This is the method in CMO that I call to bind to a 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;
}
How can I work the two together?
Thanks!