Created
October 6, 2011 08:41
-
-
Save clausjoergensen/1266871 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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