Skip to content

Instantly share code, notes, and snippets.

@clausjoergensen
Created October 6, 2011 08:41
Show Gist options
  • Save clausjoergensen/1266871 to your computer and use it in GitHub Desktop.
Save clausjoergensen/1266871 to your computer and use it in GitHub Desktop.
var mapping =
from periodControl in tariffAndLoadControlLocalType.PeriodControl
let periodControlType = periodControl.PeriodControlType
let exceptionDayKey = (int)GetExceptionDayKey(periodControlType)
let exceptionDay = ExceptionDays(periodControl)
let periods =
from period in periodControl.Period
let blockId = (int)GetBlockId(periodControlType, period.PeriodType)
let dictionary = Get(period)
let workingDays = dictionary.ContainsKey(WorkingDay)
? dictionary[WorkingDay]
: new List<PeriodShiftModel>()
let nonWorkingDays = dictionary.ContainsKey(NonWorkingDay)
? dictionary[NonWorkingDay]
: new List<PeriodShiftModel>()
let block = new TariffAndLoadControlBlock(period.Month, period.Day, workingDays, nonWorkingDays)
select new { Key = blockId, Value = block }
select new
{
Periods = periods,
ExceptionDayKey = exceptionDayKey,
ExceptionDay = exceptionDay
};
var blocks = mapping.SelectMany(x => x.Periods).ToDictionary(x => x.Key, x => x.Value);
var exceptionDays = mapping.ToDictionary(x => x.ExceptionDayKey, x => x.ExceptionDay);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment