/// <summary> /// Default initialization /// </summary> /// <param name="context"></param> void IDefaultRepositoryInitialization.InitializeDefault(RepositoryContext context) { #pragma warning disable 618 var defValues = typeof(ImportQueueRecordStateType) .GetEnumValues() .Cast<ImportQueueRecordStateType>() .Select(t => new ImportQueueRecordState() { Type = t }) .LeftOuterJoin(context.ImportQueueRecordStates, d => d.SystemName, e => e.SystemName, (d,e) => new { Default = d, Existed = e }) .Where(i => i.Existed == null) .Select(i => i.Default); context.ImportQueueRecordStates.AddRange(defValues); #pragma warning restore 618 }
void IDefaultRepositoryInitialization.InitializeDefault(RepositoryContext context) { var defColumnTypes = new ColumnType[] { new ColumnType() { SystemName = ColumnTypes.Address.ToString().ToUpper(), ImportRowValidation = true, ImportTableValidation = true, ExportColumnIndex = 1, Export = true }, new ColumnType() { SystemName = ColumnTypes.Area.ToString().ToUpper(), ImportRowValidation = false, ImportTableValidation = true, ExportColumnIndex = 2, Export = true }, new ColumnType() { SystemName = ColumnTypes.City.ToString().ToUpper(), ImportRowValidation = true, ImportTableValidation = true, ExportColumnIndex = 3, Export = true }, new ColumnType() { SystemName = ColumnTypes.Host.ToString().ToUpper(), ImportRowValidation = true, ImportTableValidation = true, ExportColumnIndex = 5, Export = true }, new ColumnType() { SystemName = ColumnTypes.Mark.ToString().ToUpper(), ImportRowValidation = false, ImportTableValidation = false, ExportColumnIndex = 4, Export = true }, new ColumnType() { SystemName = ColumnTypes.Phone.ToString().ToUpper(), ImportRowValidation = true, ImportTableValidation = true, ExportColumnIndex = 0, Export = true }, new ColumnType() { SystemName = ColumnTypes.Changed.ToString().ToUpper(), ImportRowValidation = false, ImportTableValidation = false, ExportColumnIndex = 6, Export = true }, new ColumnType() { SystemName = ColumnTypes.Created.ToString().ToUpper(), ImportRowValidation = false, ImportTableValidation = false, ExportColumnIndex = 7, Export = true }, new ColumnType() { SystemName = ColumnTypes.Exported.ToString().ToUpper(), ImportRowValidation = false, ImportTableValidation = false, ExportColumnIndex = 8, Export = true }, }; var itemsToAdd = defColumnTypes .LeftOuterJoin(context.ColumnTypes, ct => ct.SystemName, c => c.SystemName, (def, existed) => new { Default = def, Existed = existed }) .Where(i => i.Existed == null) .Select(i => i.Default) .ToArray(); context.ColumnTypes.AddRange(itemsToAdd); }
void IDefaultRepositoryInitialization.InitializeDefault(RepositoryContext context) { var defColumnTypes = typeof(MarkTypes).GetEnumValues().Cast<MarkTypes>().Select(t => new Mark() { Type = t }); #pragma warning disable 618 context.Marks.AddRange( defColumnTypes .LeftOuterJoin(context.Marks, ct => ct.SystemName, c => c.SystemName, (def, existed) => new { Default = def, Existed = existed }) .Where(i => i.Existed == null) .Select(i => i.Default) ); #pragma warning restore 618 }