Post by Hassan Gulzar on Apr 29, 2011 4:51:24 GMT -5
Hi! I'm wondering if the generated classes can have parameters. Example:
public class JobUnprocessedFindByClient
{
private Int64? _OID;
private Int64? _ClientID;
private Int64? _ClientCoordinatorID;
private String _Branch;
private String _Code;
private String _Shift;
private DateTime? _JobDate;
private Int32? _JobStatusID;
private String _CoordinatorName;
public JobUnprocessedFindByClient(
Int64? AOID, Int64? AClientID, Int64? AClientCoordinatorID,
String ABranch, String ACode, String AShift, DateTime? AJobDate,
Int32? AJobStatusID, String ACoordinatorName)
{
_OID = AOID;
_ClientID = AClientID;
_ClientCoordinatorID = AClientCoordinatorID;
_Branch = ABranch;
_Code = ACode;
_Shift = AShift;
_JobDate = AJobDate;
_JobStatusID = AJobStatusID;
_CoordinatorName = ACoordinatorName;
}
public Int64? OID { get { return _OID; } }
public Int64? ClientID { get { return _ClientID; } }
public Int64? ClientCoordinatorID { get { return _ClientCoordinatorID; } }
public String Branch { get { return _Branch; } }
public String Code { get { return _Code; } }
public String Shift { get { return _Shift; } }
public DateTime? JobDate { get { return _JobDate; } }
public Int32? JobStatusID { get { return _JobStatusID; } }
public String CoordinatorName { get { return _CoordinatorName; } }
}
public class JobUnprocessedFindByClientList: List<JobUnprocessedFindByClient>
{
public JobUnprocessedFindByClientList(ExciteDataContext DbContext)
{
var query =
from jobs in DbContext.Jobs
join locumtypes in DbContext.LocumTypes on new { LocumTypeID = jobs.LocumTypeID } equals new { LocumTypeID = locumtypes.OID }
join branches in DbContext.Branches on new { BranchID = jobs.BranchID } equals new { BranchID = branches.OID }
join jobshifttypes in DbContext.JobShiftTypes on new { JobShiftTypeID = jobs.JobShiftTypeID } equals new { JobShiftTypeID = jobshifttypes.OID }
join clientcoordinators in DbContext.ClientCoordinators on new { ClientCoordinatorID = jobs.ClientCoordinatorID } equals new { ClientCoordinatorID = clientcoordinators.OID }
where
(new int[] {1, 2 }).Contains(jobs.JobStatusID) &&
jobs.ClientID == 1
orderby
jobs.JobDate
select new {
jobs.OID,
jobs.ClientID,
ClientCoordinatorID = (System.Int64?)jobs.ClientCoordinatorID,
Branch = (branches.Name + " (" + branches.Number + ")"),
locumtypes.Code,
Shift = jobshifttypes.Name,
jobs.JobDate,
jobs.JobStatusID,
CoordinatorName = (clientcoordinators.FirstName + " " + clientcoordinators.LastName)
};
foreach (var r in query)
Add(new JobUnprocessedFindByClient(
r.OID, r.ClientID, r.ClientCoordinatorID, r.Branch, r.Code,
r.Shift, r.JobDate, r.JobStatusID, r.CoordinatorName));
}
}
The above two classes are generated by Linqer. Now, I need the where clause to be parameterized. I want to specify the Client ID and the int array. This is how I'm using the classes. Ignor my Namespace(s).
JobUnprocessedFindByClientList immediateQuery = new JobUnprocessedFindByClientList(DbContext);
Now, I'll need to apply a where extension to immediateQuery to customize the ClientID and JobStatusID.
Can this be done by introducing parameter to the constructor?
Regards.
public class JobUnprocessedFindByClient
{
private Int64? _OID;
private Int64? _ClientID;
private Int64? _ClientCoordinatorID;
private String _Branch;
private String _Code;
private String _Shift;
private DateTime? _JobDate;
private Int32? _JobStatusID;
private String _CoordinatorName;
public JobUnprocessedFindByClient(
Int64? AOID, Int64? AClientID, Int64? AClientCoordinatorID,
String ABranch, String ACode, String AShift, DateTime? AJobDate,
Int32? AJobStatusID, String ACoordinatorName)
{
_OID = AOID;
_ClientID = AClientID;
_ClientCoordinatorID = AClientCoordinatorID;
_Branch = ABranch;
_Code = ACode;
_Shift = AShift;
_JobDate = AJobDate;
_JobStatusID = AJobStatusID;
_CoordinatorName = ACoordinatorName;
}
public Int64? OID { get { return _OID; } }
public Int64? ClientID { get { return _ClientID; } }
public Int64? ClientCoordinatorID { get { return _ClientCoordinatorID; } }
public String Branch { get { return _Branch; } }
public String Code { get { return _Code; } }
public String Shift { get { return _Shift; } }
public DateTime? JobDate { get { return _JobDate; } }
public Int32? JobStatusID { get { return _JobStatusID; } }
public String CoordinatorName { get { return _CoordinatorName; } }
}
public class JobUnprocessedFindByClientList: List<JobUnprocessedFindByClient>
{
public JobUnprocessedFindByClientList(ExciteDataContext DbContext)
{
var query =
from jobs in DbContext.Jobs
join locumtypes in DbContext.LocumTypes on new { LocumTypeID = jobs.LocumTypeID } equals new { LocumTypeID = locumtypes.OID }
join branches in DbContext.Branches on new { BranchID = jobs.BranchID } equals new { BranchID = branches.OID }
join jobshifttypes in DbContext.JobShiftTypes on new { JobShiftTypeID = jobs.JobShiftTypeID } equals new { JobShiftTypeID = jobshifttypes.OID }
join clientcoordinators in DbContext.ClientCoordinators on new { ClientCoordinatorID = jobs.ClientCoordinatorID } equals new { ClientCoordinatorID = clientcoordinators.OID }
where
(new int[] {1, 2 }).Contains(jobs.JobStatusID) &&
jobs.ClientID == 1
orderby
jobs.JobDate
select new {
jobs.OID,
jobs.ClientID,
ClientCoordinatorID = (System.Int64?)jobs.ClientCoordinatorID,
Branch = (branches.Name + " (" + branches.Number + ")"),
locumtypes.Code,
Shift = jobshifttypes.Name,
jobs.JobDate,
jobs.JobStatusID,
CoordinatorName = (clientcoordinators.FirstName + " " + clientcoordinators.LastName)
};
foreach (var r in query)
Add(new JobUnprocessedFindByClient(
r.OID, r.ClientID, r.ClientCoordinatorID, r.Branch, r.Code,
r.Shift, r.JobDate, r.JobStatusID, r.CoordinatorName));
}
}
The above two classes are generated by Linqer. Now, I need the where clause to be parameterized. I want to specify the Client ID and the int array. This is how I'm using the classes. Ignor my Namespace(s).
JobUnprocessedFindByClientList immediateQuery = new JobUnprocessedFindByClientList(DbContext);
Now, I'll need to apply a where extension to immediateQuery to customize the ClientID and JobStatusID.
Can this be done by introducing parameter to the constructor?
Regards.