public Period GetPeriod(int PeriodID, int PeriodTypeID) { var result = new Period(); using (var reader = GetContext().GetReader(@" SELECT p.*, pt.PeriodTypeDescription FROM Periods p INNER JOIN PeriodTypes pt ON pt.PeriodTypeID = p.PeriodTypeID WHERE p.PeriodID = {0} AND p.PeriodTypeID = {1} ", PeriodID, PeriodTypeID)) { if(!reader.Read()) return null; result.PeriodID = reader.GetInt32("PeriodID"); result.PeriodType = new PeriodType() { PeriodTypeID = reader.GetInt32("PeriodTypeID"), PeriodTypeDescription = reader.GetString("PeriodTypeDescription") }; result.PeriodDescription = reader.GetString("PeriodDescription"); result.StartDate = reader.GetDateTime("StartDate"); result.EndDate = reader.GetDateTime("EndDate"); } return result; }
public Period GetPeriod(int PeriodID, int PeriodTypeID) { var result = new Period(); var response = GetContext().Periods.Expand("PeriodType") .Where(c => c.PeriodTypeID == PeriodTypeID) .Where(c => c.PeriodID == PeriodID) .FirstOrDefault(); if(response == null) return null; result.PeriodID = response.PeriodID; result.PeriodType = new PeriodType() { PeriodTypeID = response.PeriodTypeID, PeriodTypeDescription = response.PeriodType.PeriodTypeDescription }; result.PeriodDescription = response.PeriodDescription; result.StartDate = response.StartDate; result.EndDate = response.EndDate; return result; }