I have a WinForm App that uses multiple DataGridViews. The DGV's used to be bound to DataTables in the old SProc's DAL. As I was converting the SProcs to LINQ I originally was following suite but I am wondering if that is the "best" way.
This is a sample of what I am doing.
internal static CmoDataContext context = new CmoDataContext();
public static DataTable GetAllMembers(Guid workerID)
{
DataTable dataTable;
using (context)
{
var AllEnrollees = from enrollment in context.tblCMOEnrollments
where enrollment.CMOSocialWorkerID == workerID || enrollment.CMONurseID == workerID
select
new
{
enrollment.ADRCReferralID,
enrollment.ClientID,
enrollment.CMONurseID,
enrollment.CMOSocialWorkerID,
enrollment.DisenrollmentDate,
enrollment.DisenrollmentReasonID,
enrollment.EconomicSupportWorkerID,
enrollment.EnrollmentDate
};
dataTable = AllEnrollees.CopyLinqToDataTable();
}
return dataTable;
}
CopyLinqToDataTable()
is a custom class that, obviously, converts an IEnumerable<T>
to a DataTable.
Is there anything wrong with doing it this way? Should I be using IQueryable?
Thanks