Index: Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/AssessmentSectionEntity.cs =================================================================== diff -u -rda1df87d94dcc61aa26d5f033c6bf579c2249cdd -rb7c99708b5c1c75e45ebb7b95bec67625b1dd977 --- Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/AssessmentSectionEntity.cs (.../AssessmentSectionEntity.cs) (revision da1df87d94dcc61aa26d5f033c6bf579c2249cdd) +++ Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/AssessmentSectionEntity.cs (.../AssessmentSectionEntity.cs) (revision b7c99708b5c1c75e45ebb7b95bec67625b1dd977) @@ -41,19 +41,14 @@ BackgroundDataEntities = new HashSet(); FailureMechanismEntities = new HashSet(); HydraulicBoundaryDatabaseEntities = new HashSet(); + HydraulicBoundaryLocationCalculationsForTargetProbabilityEntities = new HashSet(); HydraulicLocationEntities = new HashSet(); } public long AssessmentSectionEntityId { get; set; } public long ProjectEntityId { get; set; } public long HydraulicLocationCalculationCollectionEntity1Id { get; set; } public long HydraulicLocationCalculationCollectionEntity2Id { get; set; } - public long HydraulicLocationCalculationCollectionEntity3Id { get; set; } - public long HydraulicLocationCalculationCollectionEntity4Id { get; set; } - public long HydraulicLocationCalculationCollectionEntity5Id { get; set; } - public long HydraulicLocationCalculationCollectionEntity6Id { get; set; } - public long HydraulicLocationCalculationCollectionEntity7Id { get; set; } - public long HydraulicLocationCalculationCollectionEntity8Id { get; set; } public string Id { get; set; } public string Name { get; set; } public string Comments { get; set; } @@ -67,12 +62,6 @@ public virtual ProjectEntity ProjectEntity { get; set; } public virtual HydraulicLocationCalculationCollectionEntity HydraulicLocationCalculationCollectionEntity { get; set; } public virtual HydraulicLocationCalculationCollectionEntity HydraulicLocationCalculationCollectionEntity1 { get; set; } - public virtual HydraulicLocationCalculationCollectionEntity HydraulicLocationCalculationCollectionEntity2 { get; set; } - public virtual HydraulicLocationCalculationCollectionEntity HydraulicLocationCalculationCollectionEntity3 { get; set; } - public virtual HydraulicLocationCalculationCollectionEntity HydraulicLocationCalculationCollectionEntity4 { get; set; } - public virtual HydraulicLocationCalculationCollectionEntity HydraulicLocationCalculationCollectionEntity5 { get; set; } - public virtual HydraulicLocationCalculationCollectionEntity HydraulicLocationCalculationCollectionEntity6 { get; set; } - public virtual HydraulicLocationCalculationCollectionEntity HydraulicLocationCalculationCollectionEntity7 { get; set; } [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection BackgroundDataEntities { get; set; } @@ -84,6 +73,9 @@ public virtual ICollection HydraulicBoundaryDatabaseEntities { get; set; } [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection HydraulicBoundaryLocationCalculationsForTargetProbabilityEntities { get; set; } + + [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection HydraulicLocationEntities { get; set; } } } \ No newline at end of file Index: Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/ClosingStructuresCalculationEntity.cs =================================================================== diff -u -rda1df87d94dcc61aa26d5f033c6bf579c2249cdd -rb7c99708b5c1c75e45ebb7b95bec67625b1dd977 --- Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/ClosingStructuresCalculationEntity.cs (.../ClosingStructuresCalculationEntity.cs) (revision da1df87d94dcc61aa26d5f033c6bf579c2249cdd) +++ Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/ClosingStructuresCalculationEntity.cs (.../ClosingStructuresCalculationEntity.cs) (revision b7c99708b5c1c75e45ebb7b95bec67625b1dd977) @@ -49,7 +49,18 @@ public int Order { get; set; } public string Name { get; set; } public string Comments { get; set; } + public byte UseBreakWater { get; set; } + public byte BreakWaterType { get; set; } + public double? BreakWaterHeight { get; set; } + public byte UseForeshore { get; set; } public double? Orientation { get; set; } + public double? StructureNormalOrientation { get; set; } + public double? StorageStructureAreaMean { get; set; } + public double? StorageStructureAreaCoefficientOfVariation { get; set; } + public double? AllowedLevelIncreaseStorageMean { get; set; } + public double? AllowedLevelIncreaseStorageStandardDeviation { get; set; } + public double? WidthFlowAperturesMean { get; set; } + public double? WidthFlowAperturesStandardDeviation { get; set; } public double? LevelCrestStructureNotClosingMean { get; set; } public double? LevelCrestStructureNotClosingStandardDeviation { get; set; } public double? InsideWaterLevelMean { get; set; } @@ -58,44 +69,32 @@ public double? ThresholdHeightOpenWeirStandardDeviation { get; set; } public double? AreaFlowAperturesMean { get; set; } public double? AreaFlowAperturesStandardDeviation { get; set; } + public double? CriticalOvertoppingDischargeMean { get; set; } + public double? CriticalOvertoppingDischargeCoefficientOfVariation { get; set; } + public double? FlowWidthAtBottomProtectionMean { get; set; } + public double? FlowWidthAtBottomProtectionStandardDeviation { get; set; } public double ProbabilityOpenStructureBeforeFlooding { get; set; } public double FailureProbabilityOpenStructure { get; set; } public int IdenticalApertures { get; set; } public double FailureProbabilityReparation { get; set; } public byte InflowModelType { get; set; } + public double FailureProbabilityStructureWithErosion { get; set; } public double? DeviationWaveDirection { get; set; } public double? DrainCoefficientMean { get; set; } public double? DrainCoefficientStandardDeviation { get; set; } public double? ModelFactorSuperCriticalFlowMean { get; set; } + public double? StormDurationMean { get; set; } public double? FactorStormDurationOpenStructure { get; set; } + public byte ShouldIllustrationPointsBeCalculated { get; set; } public byte RelevantForScenario { get; set; } public double ScenarioContribution { get; set; } public virtual CalculationGroupEntity CalculationGroupEntity { get; set; } public virtual ClosingStructureEntity ClosingStructureEntity { get; set; } + public virtual HydraulicLocationEntity HydraulicLocationEntity { get; set; } + public virtual ForeshoreProfileEntity ForeshoreProfileEntity { get; set; } [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection ClosingStructuresOutputEntities { get; set; } - - public byte UseBreakWater { get; set; } - public byte BreakWaterType { get; set; } - public double? BreakWaterHeight { get; set; } - public byte UseForeshore { get; set; } - public double? StructureNormalOrientation { get; set; } - public double? StorageStructureAreaMean { get; set; } - public double? StorageStructureAreaCoefficientOfVariation { get; set; } - public double? AllowedLevelIncreaseStorageMean { get; set; } - public double? AllowedLevelIncreaseStorageStandardDeviation { get; set; } - public double? WidthFlowAperturesMean { get; set; } - public double? WidthFlowAperturesStandardDeviation { get; set; } - public double? CriticalOvertoppingDischargeMean { get; set; } - public double? CriticalOvertoppingDischargeCoefficientOfVariation { get; set; } - public double? FlowWidthAtBottomProtectionMean { get; set; } - public double? FlowWidthAtBottomProtectionStandardDeviation { get; set; } - public double FailureProbabilityStructureWithErosion { get; set; } - public double? StormDurationMean { get; set; } - public byte ShouldIllustrationPointsBeCalculated { get; set; } - public virtual HydraulicLocationEntity HydraulicLocationEntity { get; set; } - public virtual ForeshoreProfileEntity ForeshoreProfileEntity { get; set; } } } \ No newline at end of file Index: Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/ClosingStructuresOutputEntity.cs =================================================================== diff -u -rda1df87d94dcc61aa26d5f033c6bf579c2249cdd -rb7c99708b5c1c75e45ebb7b95bec67625b1dd977 --- Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/ClosingStructuresOutputEntity.cs (.../ClosingStructuresOutputEntity.cs) (revision da1df87d94dcc61aa26d5f033c6bf579c2249cdd) +++ Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/ClosingStructuresOutputEntity.cs (.../ClosingStructuresOutputEntity.cs) (revision b7c99708b5c1c75e45ebb7b95bec67625b1dd977) @@ -35,9 +35,9 @@ public long ClosingStructuresOutputEntityId { get; set; } public long ClosingStructuresCalculationEntityId { get; set; } public long? GeneralResultFaultTreeIllustrationPointEntityId { get; set; } + public double? Reliability { get; set; } public virtual ClosingStructuresCalculationEntity ClosingStructuresCalculationEntity { get; set; } public virtual GeneralResultFaultTreeIllustrationPointEntity GeneralResultFaultTreeIllustrationPointEntity { get; set; } - public double? Reliability { get; set; } } } \ No newline at end of file Index: Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/GeneralResultFaultTreeIllustrationPointEntity.cs =================================================================== diff -u -rda1df87d94dcc61aa26d5f033c6bf579c2249cdd -rb7c99708b5c1c75e45ebb7b95bec67625b1dd977 --- Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/GeneralResultFaultTreeIllustrationPointEntity.cs (.../GeneralResultFaultTreeIllustrationPointEntity.cs) (revision da1df87d94dcc61aa26d5f033c6bf579c2249cdd) +++ Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/GeneralResultFaultTreeIllustrationPointEntity.cs (.../GeneralResultFaultTreeIllustrationPointEntity.cs) (revision b7c99708b5c1c75e45ebb7b95bec67625b1dd977) @@ -51,6 +51,8 @@ } public long GeneralResultFaultTreeIllustrationPointEntityId { get; set; } + public string GoverningWindDirectionName { get; set; } + public double GoverningWindDirectionAngle { get; set; } [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection ClosingStructuresOutputEntities { get; set; } @@ -79,9 +81,6 @@ [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection TopLevelFaultTreeIllustrationPointEntities { get; set; } - public string GoverningWindDirectionName { get; set; } - public double GoverningWindDirectionAngle { get; set; } - [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection StochastEntities { get; set; } } Index: Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/GeneralResultSubMechanismIllustrationPointEntity.cs =================================================================== diff -u -rda1df87d94dcc61aa26d5f033c6bf579c2249cdd -rb7c99708b5c1c75e45ebb7b95bec67625b1dd977 --- Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/GeneralResultSubMechanismIllustrationPointEntity.cs (.../GeneralResultSubMechanismIllustrationPointEntity.cs) (revision da1df87d94dcc61aa26d5f033c6bf579c2249cdd) +++ Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/GeneralResultSubMechanismIllustrationPointEntity.cs (.../GeneralResultSubMechanismIllustrationPointEntity.cs) (revision b7c99708b5c1c75e45ebb7b95bec67625b1dd977) @@ -46,6 +46,8 @@ } public long GeneralResultSubMechanismIllustrationPointEntityId { get; set; } + public string GoverningWindDirectionName { get; set; } + public double GoverningWindDirectionAngle { get; set; } [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection HydraulicLocationOutputEntities { get; set; } @@ -59,9 +61,6 @@ [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection TopLevelSubMechanismIllustrationPointEntities { get; set; } - public string GoverningWindDirectionName { get; set; } - public double GoverningWindDirectionAngle { get; set; } - [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection StochastEntities { get; set; } } Index: Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/GrassCoverErosionOutwardsFailureMechanismMetaEntity.cs =================================================================== diff -u -rda1df87d94dcc61aa26d5f033c6bf579c2249cdd -rb7c99708b5c1c75e45ebb7b95bec67625b1dd977 --- Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/GrassCoverErosionOutwardsFailureMechanismMetaEntity.cs (.../GrassCoverErosionOutwardsFailureMechanismMetaEntity.cs) (revision da1df87d94dcc61aa26d5f033c6bf579c2249cdd) +++ Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/GrassCoverErosionOutwardsFailureMechanismMetaEntity.cs (.../GrassCoverErosionOutwardsFailureMechanismMetaEntity.cs) (revision b7c99708b5c1c75e45ebb7b95bec67625b1dd977) @@ -34,21 +34,9 @@ { public long GrassCoverErosionOutwardsFailureMechanismMetaEntityId { get; set; } public long FailureMechanismEntityId { get; set; } - public long HydraulicLocationCalculationCollectionEntity1Id { get; set; } - public long HydraulicLocationCalculationCollectionEntity2Id { get; set; } - public long HydraulicLocationCalculationCollectionEntity3Id { get; set; } - public long HydraulicLocationCalculationCollectionEntity4Id { get; set; } - public long HydraulicLocationCalculationCollectionEntity5Id { get; set; } - public long HydraulicLocationCalculationCollectionEntity6Id { get; set; } public double N { get; set; } public string ForeshoreProfileCollectionSourcePath { get; set; } public virtual FailureMechanismEntity FailureMechanismEntity { get; set; } - public virtual HydraulicLocationCalculationCollectionEntity HydraulicLocationCalculationCollectionEntity { get; set; } - public virtual HydraulicLocationCalculationCollectionEntity HydraulicLocationCalculationCollectionEntity1 { get; set; } - public virtual HydraulicLocationCalculationCollectionEntity HydraulicLocationCalculationCollectionEntity2 { get; set; } - public virtual HydraulicLocationCalculationCollectionEntity HydraulicLocationCalculationCollectionEntity3 { get; set; } - public virtual HydraulicLocationCalculationCollectionEntity HydraulicLocationCalculationCollectionEntity4 { get; set; } - public virtual HydraulicLocationCalculationCollectionEntity HydraulicLocationCalculationCollectionEntity5 { get; set; } } } \ No newline at end of file Index: Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/HeightStructuresCalculationEntity.cs =================================================================== diff -u -rda1df87d94dcc61aa26d5f033c6bf579c2249cdd -rb7c99708b5c1c75e45ebb7b95bec67625b1dd977 --- Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/HeightStructuresCalculationEntity.cs (.../HeightStructuresCalculationEntity.cs) (revision da1df87d94dcc61aa26d5f033c6bf579c2249cdd) +++ Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/HeightStructuresCalculationEntity.cs (.../HeightStructuresCalculationEntity.cs) (revision b7c99708b5c1c75e45ebb7b95bec67625b1dd977) @@ -50,18 +50,6 @@ public string Name { get; set; } public string Comments { get; set; } public double? ModelFactorSuperCriticalFlowMean { get; set; } - public double? LevelCrestStructureMean { get; set; } - public double? LevelCrestStructureStandardDeviation { get; set; } - public double? DeviationWaveDirection { get; set; } - public byte RelevantForScenario { get; set; } - public double ScenarioContribution { get; set; } - - public virtual CalculationGroupEntity CalculationGroupEntity { get; set; } - public virtual HeightStructureEntity HeightStructureEntity { get; set; } - - [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection HeightStructuresOutputEntities { get; set; } - public double? StructureNormalOrientation { get; set; } public double? AllowedLevelIncreaseStorageMean { get; set; } public double? AllowedLevelIncreaseStorageStandardDeviation { get; set; } @@ -75,12 +63,23 @@ public double? WidthFlowAperturesMean { get; set; } public double? WidthFlowAperturesStandardDeviation { get; set; } public double? StormDurationMean { get; set; } + public double? LevelCrestStructureMean { get; set; } + public double? LevelCrestStructureStandardDeviation { get; set; } + public double? DeviationWaveDirection { get; set; } public byte UseBreakWater { get; set; } public byte UseForeshore { get; set; } public byte BreakWaterType { get; set; } public double? BreakWaterHeight { get; set; } public byte ShouldIllustrationPointsBeCalculated { get; set; } + public byte RelevantForScenario { get; set; } + public double ScenarioContribution { get; set; } + + public virtual CalculationGroupEntity CalculationGroupEntity { get; set; } public virtual ForeshoreProfileEntity ForeshoreProfileEntity { get; set; } + public virtual HeightStructureEntity HeightStructureEntity { get; set; } public virtual HydraulicLocationEntity HydraulicLocationEntity { get; set; } + + [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection HeightStructuresOutputEntities { get; set; } } } \ No newline at end of file Index: Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/HeightStructuresOutputEntity.cs =================================================================== diff -u -rda1df87d94dcc61aa26d5f033c6bf579c2249cdd -rb7c99708b5c1c75e45ebb7b95bec67625b1dd977 --- Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/HeightStructuresOutputEntity.cs (.../HeightStructuresOutputEntity.cs) (revision da1df87d94dcc61aa26d5f033c6bf579c2249cdd) +++ Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/HeightStructuresOutputEntity.cs (.../HeightStructuresOutputEntity.cs) (revision b7c99708b5c1c75e45ebb7b95bec67625b1dd977) @@ -35,9 +35,9 @@ public long HeightStructuresOutputEntityId { get; set; } public long HeightStructuresCalculationEntityId { get; set; } public long? GeneralResultFaultTreeIllustrationPointEntityId { get; set; } - public virtual HeightStructuresCalculationEntity HeightStructuresCalculationEntity { get; set; } + public double? Reliability { get; set; } public virtual GeneralResultFaultTreeIllustrationPointEntity GeneralResultFaultTreeIllustrationPointEntity { get; set; } - public double? Reliability { get; set; } + public virtual HeightStructuresCalculationEntity HeightStructuresCalculationEntity { get; set; } } } \ No newline at end of file Index: Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/HydraulicBoundaryLocationCalculationsForTargetProbabilityEntity.cs =================================================================== diff -u --- Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/HydraulicBoundaryLocationCalculationsForTargetProbabilityEntity.cs (revision 0) +++ Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/HydraulicBoundaryLocationCalculationsForTargetProbabilityEntity.cs (revision b7c99708b5c1c75e45ebb7b95bec67625b1dd977) @@ -0,0 +1,54 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +//------------------------------------------------------------------------------ +// +// This code was generated from a template. +// +// Manual changes to this file may cause unexpected behavior in your application. +// Manual changes to this file will be overwritten if the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; + +namespace Riskeer.Storage.Core.DbContext +{ + public class HydraulicBoundaryLocationCalculationsForTargetProbabilityEntity + { + [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public HydraulicBoundaryLocationCalculationsForTargetProbabilityEntity() + { + HydraulicLocationCalculationEntities = new HashSet(); + } + + public long HydraulicBoundaryLocationCalculationsForTargetProbabilityEntityId { get; set; } + public long AssessmentSectionEntityId { get; set; } + public byte HydraulicBoundaryLocationCalculationType { get; set; } + public double TargetProbability { get; set; } + + public virtual AssessmentSectionEntity AssessmentSectionEntity { get; set; } + + [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection HydraulicLocationCalculationEntities { get; set; } + } +} \ No newline at end of file Index: Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/HydraulicLocationCalculationCollectionEntity.cs =================================================================== diff -u -rda1df87d94dcc61aa26d5f033c6bf579c2249cdd -rb7c99708b5c1c75e45ebb7b95bec67625b1dd977 --- Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/HydraulicLocationCalculationCollectionEntity.cs (.../HydraulicLocationCalculationCollectionEntity.cs) (revision da1df87d94dcc61aa26d5f033c6bf579c2249cdd) +++ Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/HydraulicLocationCalculationCollectionEntity.cs (.../HydraulicLocationCalculationCollectionEntity.cs) (revision b7c99708b5c1c75e45ebb7b95bec67625b1dd977) @@ -40,18 +40,6 @@ { AssessmentSectionEntities = new HashSet(); AssessmentSectionEntities1 = new HashSet(); - AssessmentSectionEntities2 = new HashSet(); - AssessmentSectionEntities3 = new HashSet(); - AssessmentSectionEntities4 = new HashSet(); - AssessmentSectionEntities5 = new HashSet(); - AssessmentSectionEntities6 = new HashSet(); - AssessmentSectionEntities7 = new HashSet(); - GrassCoverErosionOutwardsFailureMechanismMetaEntities = new HashSet(); - GrassCoverErosionOutwardsFailureMechanismMetaEntities1 = new HashSet(); - GrassCoverErosionOutwardsFailureMechanismMetaEntities2 = new HashSet(); - GrassCoverErosionOutwardsFailureMechanismMetaEntities3 = new HashSet(); - GrassCoverErosionOutwardsFailureMechanismMetaEntities4 = new HashSet(); - GrassCoverErosionOutwardsFailureMechanismMetaEntities5 = new HashSet(); HydraulicLocationCalculationEntities = new HashSet(); } @@ -64,42 +52,6 @@ public virtual ICollection AssessmentSectionEntities1 { get; set; } [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection AssessmentSectionEntities2 { get; set; } - - [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection AssessmentSectionEntities3 { get; set; } - - [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection AssessmentSectionEntities4 { get; set; } - - [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection AssessmentSectionEntities5 { get; set; } - - [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection AssessmentSectionEntities6 { get; set; } - - [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection AssessmentSectionEntities7 { get; set; } - - [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection GrassCoverErosionOutwardsFailureMechanismMetaEntities { get; set; } - - [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection GrassCoverErosionOutwardsFailureMechanismMetaEntities1 { get; set; } - - [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection GrassCoverErosionOutwardsFailureMechanismMetaEntities2 { get; set; } - - [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection GrassCoverErosionOutwardsFailureMechanismMetaEntities3 { get; set; } - - [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection GrassCoverErosionOutwardsFailureMechanismMetaEntities4 { get; set; } - - [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] - public virtual ICollection GrassCoverErosionOutwardsFailureMechanismMetaEntities5 { get; set; } - - [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection HydraulicLocationCalculationEntities { get; set; } } } \ No newline at end of file Index: Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/HydraulicLocationCalculationEntity.cs =================================================================== diff -u -rda1df87d94dcc61aa26d5f033c6bf579c2249cdd -rb7c99708b5c1c75e45ebb7b95bec67625b1dd977 --- Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/HydraulicLocationCalculationEntity.cs (.../HydraulicLocationCalculationEntity.cs) (revision da1df87d94dcc61aa26d5f033c6bf579c2249cdd) +++ Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/HydraulicLocationCalculationEntity.cs (.../HydraulicLocationCalculationEntity.cs) (revision b7c99708b5c1c75e45ebb7b95bec67625b1dd977) @@ -39,17 +39,24 @@ public HydraulicLocationCalculationEntity() { HydraulicLocationOutputEntities = new HashSet(); + HydraulicBoundaryLocationCalculationsForTargetProbabilityEntities = new HashSet(); + HydraulicLocationCalculationCollectionEntities = new HashSet(); } public long HydraulicLocationCalculationEntityId { get; set; } public long HydraulicLocationEntityId { get; set; } public long HydraulicLocationCalculationCollectionEntityId { get; set; } public byte ShouldIllustrationPointsBeCalculated { get; set; } - public virtual HydraulicLocationCalculationCollectionEntity HydraulicLocationCalculationCollectionEntity { get; set; } public virtual HydraulicLocationEntity HydraulicLocationEntity { get; set; } [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection HydraulicLocationOutputEntities { get; set; } + + [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection HydraulicBoundaryLocationCalculationsForTargetProbabilityEntities { get; set; } + + [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection HydraulicLocationCalculationCollectionEntities { get; set; } } } \ No newline at end of file Index: Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/RiskeerEntities.Context.cs =================================================================== diff -u -rda1df87d94dcc61aa26d5f033c6bf579c2249cdd -rb7c99708b5c1c75e45ebb7b95bec67625b1dd977 --- Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/RiskeerEntities.Context.cs (.../RiskeerEntities.Context.cs) (revision da1df87d94dcc61aa26d5f033c6bf579c2249cdd) +++ Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/RiskeerEntities.Context.cs (.../RiskeerEntities.Context.cs) (revision b7c99708b5c1c75e45ebb7b95bec67625b1dd977) @@ -75,6 +75,7 @@ public virtual DbSet HeightStructuresOutputEntities { get; set; } public virtual DbSet HeightStructuresSectionResultEntities { get; set; } public virtual DbSet HydraulicBoundaryDatabaseEntities { get; set; } + public virtual DbSet HydraulicBoundaryLocationCalculationsForTargetProbabilityEntities { get; set; } public virtual DbSet HydraulicLocationCalculationCollectionEntities { get; set; } public virtual DbSet HydraulicLocationCalculationEntities { get; set; } public virtual DbSet HydraulicLocationEntities { get; set; } @@ -137,7 +138,7 @@ /// but before the model has been locked down and used to initialize the . /// /// The that defines the model for the context being created. - /// Thrown because the is created in a 'code first' approach. + /// Thrown because the is created in a 'code first' approach. protected override void OnModelCreating(DbModelBuilder modelBuilder) { throw new UnintentionalCodeFirstException(); Index: Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/RiskeerEntities.Context.tt =================================================================== diff -u -rda1df87d94dcc61aa26d5f033c6bf579c2249cdd -rb7c99708b5c1c75e45ebb7b95bec67625b1dd977 --- Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/RiskeerEntities.Context.tt (.../RiskeerEntities.Context.tt) (revision da1df87d94dcc61aa26d5f033c6bf579c2249cdd) +++ Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/RiskeerEntities.Context.tt (.../RiskeerEntities.Context.tt) (revision b7c99708b5c1c75e45ebb7b95bec67625b1dd977) @@ -1,21 +1,22 @@ <#@ template language="C#" debug="false" hostspecific="true"#> <#@ include file="EF6.Utility.CS.ttinclude"#><#@ - output extension=".cs"#><#@ import namespace="System.Collections" #><# - const string inputFile = @"RiskeerEntities.edmx"; - var textTransform = DynamicTextTransformation.Create(this); - var code = new CodeGenerationTools(this); - var ef = new MetadataTools(this); - var typeMapper = new TypeMapper(code, ef, textTransform.Errors); - var loader = new EdmMetadataLoader(textTransform.Host, textTransform.Errors); - var itemCollection = loader.CreateEdmItemCollection(inputFile); - var modelNamespace = loader.GetModelNamespace(inputFile); - var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef); + output extension=".cs"#><# - var container = itemCollection.OfType().FirstOrDefault(); - if (container == null) - { - return string.Empty; - } +const string inputFile = @"RiskeerEntities.edmx"; +var textTransform = DynamicTextTransformation.Create(this); +var code = new CodeGenerationTools(this); +var ef = new MetadataTools(this); +var typeMapper = new TypeMapper(code, ef, textTransform.Errors); +var loader = new EdmMetadataLoader(textTransform.Host, textTransform.Errors); +var itemCollection = loader.CreateEdmItemCollection(inputFile); +var modelNamespace = loader.GetModelNamespace(inputFile); +var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef); + +var container = itemCollection.OfType().FirstOrDefault(); +if (container == null) +{ + return string.Empty; +} #> // Copyright (C) Stichting Deltares 2021. All rights reserved. // @@ -40,43 +41,43 @@ //------------------------------------------------------------------------------ // -// <#= CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1") #> +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#> // -// <#= CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2") #> -// <#= CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3") #> +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#> +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#> // //------------------------------------------------------------------------------ using System.Data.Entity; using System.Data.Entity.Infrastructure; <# - if (container.FunctionImports.Any()) - { +if (container.FunctionImports.Any()) +{ #> using System.Data.Entity.Core.Objects; using System.Linq; <# - } +} #> <# - var codeNamespace = code.VsNamespaceSuggestion(); - if (!String.IsNullOrEmpty(codeNamespace)) - { +var codeNamespace = code.VsNamespaceSuggestion(); +if (!String.IsNullOrEmpty(codeNamespace)) +{ #> -namespace <#= code.EscapeNamespace(codeNamespace) #> +namespace <#=code.EscapeNamespace(codeNamespace)#> { <# - PushIndent(" "); - } + PushIndent(" "); +} #> -<#= Accessibility.ForType(container) #> partial class <#= code.Escape(container) #> : System.Data.Entity.DbContext +<#=Accessibility.ForType(container)#> partial class <#=code.Escape(container)#> : System.Data.Entity.DbContext { <# foreach (var entitySet in container.BaseEntitySets.OfType()) { #> - <#= codeStringGenerator.DbSet(entitySet) #> + <#=codeStringGenerator.DbSet(entitySet)#> <# } @@ -98,531 +99,536 @@ } } <# - if (!String.IsNullOrEmpty(codeNamespace)) - { - PopIndent(); + +if (!String.IsNullOrEmpty(codeNamespace)) +{ + PopIndent(); #> }<# - } +} #> <#+ - private void WriteFunctionImport(TypeMapper typeMapper, CodeStringGenerator codeStringGenerator, EdmFunction edmFunction, string modelNamespace, bool includeMergeOption) + +private void WriteFunctionImport(TypeMapper typeMapper, CodeStringGenerator codeStringGenerator, EdmFunction edmFunction, string modelNamespace, bool includeMergeOption) +{ + if (typeMapper.IsComposable(edmFunction)) { - if (typeMapper.IsComposable(edmFunction)) - { #> - [DbFunction("<#= edmFunction.NamespaceName #>", "<#= edmFunction.Name #>")] - <#= codeStringGenerator.ComposableFunctionMethod(edmFunction, modelNamespace) #> + [DbFunction("<#=edmFunction.NamespaceName#>", "<#=edmFunction.Name#>")] + <#=codeStringGenerator.ComposableFunctionMethod(edmFunction, modelNamespace)#> { <#+ - codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter); + codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter); #> - <#= codeStringGenerator.ComposableCreateQuery(edmFunction, modelNamespace) #> + <#=codeStringGenerator.ComposableCreateQuery(edmFunction, modelNamespace)#> } <#+ - } - else - { + } + else + { #> - <#= codeStringGenerator.FunctionMethod(edmFunction, modelNamespace, includeMergeOption) #> + <#=codeStringGenerator.FunctionMethod(edmFunction, modelNamespace, includeMergeOption)#> { <#+ - codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter); + codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter); #> - <#= codeStringGenerator.ExecuteFunction(edmFunction, modelNamespace, includeMergeOption) #> + <#=codeStringGenerator.ExecuteFunction(edmFunction, modelNamespace, includeMergeOption)#> } <#+ - if (typeMapper.GenerateMergeOptionFunction(edmFunction, includeMergeOption)) - { - WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: true); - } + if (typeMapper.GenerateMergeOptionFunction(edmFunction, includeMergeOption)) + { + WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: true); } } +} - public void WriteFunctionParameter(string name, string isNotNull, string notNullInit, string nullInit) - { +public void WriteFunctionParameter(string name, string isNotNull, string notNullInit, string nullInit) +{ #> - var <#= name #> = <#= isNotNull #> ? - <#= notNullInit #> : - <#= nullInit #>; + var <#=name#> = <#=isNotNull#> ? + <#=notNullInit#> : + <#=nullInit#>; <#+ - } +} - public const string TemplateId = "CSharp_DbContext_Context_EF6"; +public const string TemplateId = "CSharp_DbContext_Context_EF6"; - public class CodeStringGenerator +public class CodeStringGenerator +{ + private readonly CodeGenerationTools _code; + private readonly TypeMapper _typeMapper; + private readonly MetadataTools _ef; + + public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef) { - private readonly CodeGenerationTools _code; - private readonly TypeMapper _typeMapper; - private readonly MetadataTools _ef; + ArgumentNotNull(code, "code"); + ArgumentNotNull(typeMapper, "typeMapper"); + ArgumentNotNull(ef, "ef"); - public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef) - { - ArgumentNotNull(code, "code"); - ArgumentNotNull(typeMapper, "typeMapper"); - ArgumentNotNull(ef, "ef"); + _code = code; + _typeMapper = typeMapper; + _ef = ef; + } - _code = code; - _typeMapper = typeMapper; - _ef = ef; - } + public string Property(EdmProperty edmProperty) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1} {2} {{ {3}get; {4}set; }}", + Accessibility.ForProperty(edmProperty), + _typeMapper.GetTypeName(edmProperty.TypeUsage), + _code.Escape(edmProperty), + _code.SpaceAfter(Accessibility.ForGetter(edmProperty)), + _code.SpaceAfter(Accessibility.ForSetter(edmProperty))); + } - public string Property(EdmProperty edmProperty) - { - return string.Format( - CultureInfo.InvariantCulture, - "{0} {1} {2} {{ {3}get; {4}set; }}", - Accessibility.ForProperty(edmProperty), - _typeMapper.GetTypeName(edmProperty.TypeUsage), - _code.Escape(edmProperty), - _code.SpaceAfter(Accessibility.ForGetter(edmProperty)), - _code.SpaceAfter(Accessibility.ForSetter(edmProperty))); + public string NavigationProperty(NavigationProperty navProp) + { + var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType()); + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1} {2} {{ {3}get; {4}set; }}", + AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)), + navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType, + _code.Escape(navProp), + _code.SpaceAfter(Accessibility.ForGetter(navProp)), + _code.SpaceAfter(Accessibility.ForSetter(navProp))); + } + + public string AccessibilityAndVirtual(string accessibility) + { + return accessibility + (accessibility != "private" ? " virtual" : ""); + } + + public string EntityClassOpening(EntityType entity) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1}partial class {2}{3}", + Accessibility.ForType(entity), + _code.SpaceAfter(_code.AbstractOption(entity)), + _code.Escape(entity), + _code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType))); + } + + public string EnumOpening(SimpleType enumType) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} enum {1} : {2}", + Accessibility.ForType(enumType), + _code.Escape(enumType), + _code.Escape(_typeMapper.UnderlyingClrType(enumType))); } - - public string NavigationProperty(NavigationProperty navProp) + + public void WriteFunctionParameters(EdmFunction edmFunction, Action writeParameter) + { + var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef); + foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable)) { - var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType()); - return string.Format( - CultureInfo.InvariantCulture, - "{0} {1} {2} {{ {3}get; {4}set; }}", - AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)), - navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType, - _code.Escape(navProp), - _code.SpaceAfter(Accessibility.ForGetter(navProp)), - _code.SpaceAfter(Accessibility.ForSetter(navProp))); + var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null"; + var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")"; + var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))"; + writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit); } + } + + public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace) + { + var parameters = _typeMapper.GetParameters(edmFunction); + + return string.Format( + CultureInfo.InvariantCulture, + "{0} IQueryable<{1}> {2}({3})", + AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)), + _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace), + _code.Escape(edmFunction), + string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray())); + } + + public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace) + { + var parameters = _typeMapper.GetParameters(edmFunction); + + return string.Format( + CultureInfo.InvariantCulture, + "return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});", + _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace), + edmFunction.NamespaceName, + edmFunction.Name, + string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()), + _code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()))); + } + + public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption) + { + var parameters = _typeMapper.GetParameters(edmFunction); + var returnType = _typeMapper.GetReturnType(edmFunction); - public string AccessibilityAndVirtual(string accessibility) + var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()); + if (includeMergeOption) { - return accessibility + (accessibility != "private" ? " virtual" : ""); + paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption"; } - public string EntityClassOpening(EntityType entity) - { - return string.Format( - CultureInfo.InvariantCulture, - "{0} {1}partial class {2}{3}", - Accessibility.ForType(entity), - _code.SpaceAfter(_code.AbstractOption(entity)), - _code.Escape(entity), - _code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType))); - } + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1} {2}({3})", + AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)), + returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">", + _code.Escape(edmFunction), + paramList); + } + + public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption) + { + var parameters = _typeMapper.GetParameters(edmFunction); + var returnType = _typeMapper.GetReturnType(edmFunction); - public string EnumOpening(SimpleType enumType) + var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())); + if (includeMergeOption) { - return string.Format( - CultureInfo.InvariantCulture, - "{0} enum {1} : {2}", - Accessibility.ForType(enumType), - _code.Escape(enumType), - _code.Escape(_typeMapper.UnderlyingClrType(enumType))); + callParams = ", mergeOption" + callParams; } + + return string.Format( + CultureInfo.InvariantCulture, + "return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});", + returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">", + edmFunction.Name, + callParams); + } + + public string DbSet(EntitySet entitySet) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} virtual DbSet<{1}> {2} {{ get; set; }}", + Accessibility.ForReadOnlyProperty(entitySet), + _typeMapper.GetTypeName(entitySet.ElementType), + _code.Escape(entitySet)); + } - public void WriteFunctionParameters(EdmFunction edmFunction, Action writeParameter) - { - var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef); - foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable)) - { - var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null"; - var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")"; - var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))"; - writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit); - } - } + public string DbSetInitializer(EntitySet entitySet) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} = Set<{1}>();", + _code.Escape(entitySet), + _typeMapper.GetTypeName(entitySet.ElementType)); + } - public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace) - { - var parameters = _typeMapper.GetParameters(edmFunction); - - return string.Format( + public string UsingDirectives(bool inHeader, bool includeCollections = true) + { + return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion()) + ? string.Format( CultureInfo.InvariantCulture, - "{0} IQueryable<{1}> {2}({3})", - AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)), - _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace), - _code.Escape(edmFunction), - string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray())); - } + "{0}using System;{1}" + + "{2}", + inHeader ? Environment.NewLine : "", + includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "", + inHeader ? "" : Environment.NewLine) + : ""; + } +} - public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace) - { - var parameters = _typeMapper.GetParameters(edmFunction); +public class TypeMapper +{ + private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName"; - return string.Format( - CultureInfo.InvariantCulture, - "return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});", - _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace), - edmFunction.NamespaceName, - edmFunction.Name, - string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()), - _code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()))); - } + private readonly System.Collections.IList _errors; + private readonly CodeGenerationTools _code; + private readonly MetadataTools _ef; - public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption) - { - var parameters = _typeMapper.GetParameters(edmFunction); - var returnType = _typeMapper.GetReturnType(edmFunction); + public static string FixNamespaces(string typeName) + { + return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial."); + } - var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()); - if (includeMergeOption) - { - paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption"; - } + public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors) + { + ArgumentNotNull(code, "code"); + ArgumentNotNull(ef, "ef"); + ArgumentNotNull(errors, "errors"); - return string.Format( - CultureInfo.InvariantCulture, - "{0} {1} {2}({3})", - AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)), - returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">", - _code.Escape(edmFunction), - paramList); - } + _code = code; + _ef = ef; + _errors = errors; + } - public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption) - { - var parameters = _typeMapper.GetParameters(edmFunction); - var returnType = _typeMapper.GetReturnType(edmFunction); + public string GetTypeName(TypeUsage typeUsage) + { + return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null); + } - var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())); - if (includeMergeOption) - { - callParams = ", mergeOption" + callParams; - } + public string GetTypeName(EdmType edmType) + { + return GetTypeName(edmType, isNullable: null, modelNamespace: null); + } - return string.Format( - CultureInfo.InvariantCulture, - "return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});", - returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">", - edmFunction.Name, - callParams); - } - - public string DbSet(EntitySet entitySet) - { - return string.Format( - CultureInfo.InvariantCulture, - "{0} virtual DbSet<{1}> {2} {{ get; set; }}", - Accessibility.ForReadOnlyProperty(entitySet), - _typeMapper.GetTypeName(entitySet.ElementType), - _code.Escape(entitySet)); - } - - public string DbSetInitializer(EntitySet entitySet) - { - return string.Format( - CultureInfo.InvariantCulture, - "{0} = Set<{1}>();", - _code.Escape(entitySet), - _typeMapper.GetTypeName(entitySet.ElementType)); - } - - public string UsingDirectives(bool inHeader, bool includeCollections = true) - { - return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion()) - ? string.Format( - CultureInfo.InvariantCulture, - "{0}using System;{1}" + - "{2}", - inHeader ? Environment.NewLine : "", - includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "", - inHeader ? "" : Environment.NewLine) - : ""; - } + public string GetTypeName(TypeUsage typeUsage, string modelNamespace) + { + return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace); } - public class TypeMapper + public string GetTypeName(EdmType edmType, string modelNamespace) { - private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName"; + return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace); + } - private readonly IList _errors; - private readonly CodeGenerationTools _code; - private readonly MetadataTools _ef; - - public static string FixNamespaces(string typeName) + public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace) + { + if (edmType == null) { - return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial."); + return null; } - public TypeMapper(CodeGenerationTools code, MetadataTools ef, IList errors) + var collectionType = edmType as CollectionType; + if (collectionType != null) { - ArgumentNotNull(code, "code"); - ArgumentNotNull(ef, "ef"); - ArgumentNotNull(errors, "errors"); - - _code = code; - _ef = ef; - _errors = errors; + return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace)); } - public string GetTypeName(TypeUsage typeUsage) - { - return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null); - } + var typeName = _code.Escape(edmType.MetadataProperties + .Where(p => p.Name == ExternalTypeNameAttributeName) + .Select(p => (string)p.Value) + .FirstOrDefault()) + ?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ? + _code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) : + _code.Escape(edmType)); - public string GetTypeName(EdmType edmType) + if (edmType is StructuralType) { - return GetTypeName(edmType, isNullable: null, modelNamespace: null); + return typeName; } - public string GetTypeName(TypeUsage typeUsage, string modelNamespace) + if (edmType is SimpleType) { - return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace); - } - - public string GetTypeName(EdmType edmType, string modelNamespace) - { - return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace); - } - - public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace) - { - if (edmType == null) + var clrType = UnderlyingClrType(edmType); + if (!IsEnumType(edmType)) { - return null; + typeName = _code.Escape(clrType); } - var collectionType = edmType as CollectionType; - if (collectionType != null) - { - return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace)); - } + typeName = FixNamespaces(typeName); - var typeName = _code.Escape(edmType.MetadataProperties - .Where(p => p.Name == ExternalTypeNameAttributeName) - .Select(p => (string) p.Value) - .FirstOrDefault()) - ?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ? - _code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) : - _code.Escape(edmType)); - - if (edmType is StructuralType) - { - return typeName; - } - - if (edmType is SimpleType) - { - var clrType = UnderlyingClrType(edmType); - if (!IsEnumType(edmType)) - { - typeName = _code.Escape(clrType); - } - - typeName = FixNamespaces(typeName); - - return clrType.IsValueType && isNullable == true ? - String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) : - typeName; - } - - throw new ArgumentException("edmType"); + return clrType.IsValueType && isNullable == true ? + String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) : + typeName; } - public Type UnderlyingClrType(EdmType edmType) - { - ArgumentNotNull(edmType, "edmType"); + throw new ArgumentException("edmType"); + } + + public Type UnderlyingClrType(EdmType edmType) + { + ArgumentNotNull(edmType, "edmType"); - var primitiveType = edmType as PrimitiveType; - if (primitiveType != null) - { - return primitiveType.ClrEquivalentType; - } - - if (IsEnumType(edmType)) - { - return GetEnumUnderlyingType(edmType).ClrEquivalentType; - } - - return typeof(object); - } - - public object GetEnumMemberValue(MetadataItem enumMember) + var primitiveType = edmType as PrimitiveType; + if (primitiveType != null) { - ArgumentNotNull(enumMember, "enumMember"); - - var valueProperty = enumMember.GetType().GetProperty("Value"); - return valueProperty == null ? null : valueProperty.GetValue(enumMember, null); + return primitiveType.ClrEquivalentType; } - public string GetEnumMemberName(MetadataItem enumMember) + if (IsEnumType(edmType)) { - ArgumentNotNull(enumMember, "enumMember"); - - var nameProperty = enumMember.GetType().GetProperty("Name"); - return nameProperty == null ? null : (string) nameProperty.GetValue(enumMember, null); + return GetEnumUnderlyingType(edmType).ClrEquivalentType; } - public IEnumerable GetEnumMembers(EdmType enumType) - { - ArgumentNotNull(enumType, "enumType"); + return typeof(object); + } + + public object GetEnumMemberValue(MetadataItem enumMember) + { + ArgumentNotNull(enumMember, "enumMember"); + + var valueProperty = enumMember.GetType().GetProperty("Value"); + return valueProperty == null ? null : valueProperty.GetValue(enumMember, null); + } + + public string GetEnumMemberName(MetadataItem enumMember) + { + ArgumentNotNull(enumMember, "enumMember"); + + var nameProperty = enumMember.GetType().GetProperty("Name"); + return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null); + } - var membersProperty = enumType.GetType().GetProperty("Members"); - return membersProperty != null - ? (IEnumerable) membersProperty.GetValue(enumType, null) - : Enumerable.Empty(); - } + public System.Collections.IEnumerable GetEnumMembers(EdmType enumType) + { + ArgumentNotNull(enumType, "enumType"); - public bool EnumIsFlags(EdmType enumType) - { - ArgumentNotNull(enumType, "enumType"); + var membersProperty = enumType.GetType().GetProperty("Members"); + return membersProperty != null + ? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null) + : Enumerable.Empty(); + } + + public bool EnumIsFlags(EdmType enumType) + { + ArgumentNotNull(enumType, "enumType"); + + var isFlagsProperty = enumType.GetType().GetProperty("IsFlags"); + return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null); + } - var isFlagsProperty = enumType.GetType().GetProperty("IsFlags"); - return isFlagsProperty != null && (bool) isFlagsProperty.GetValue(enumType, null); - } + public bool IsEnumType(GlobalItem edmType) + { + ArgumentNotNull(edmType, "edmType"); - public bool IsEnumType(GlobalItem edmType) - { - ArgumentNotNull(edmType, "edmType"); + return edmType.GetType().Name == "EnumType"; + } - return edmType.GetType().Name == "EnumType"; - } + public PrimitiveType GetEnumUnderlyingType(EdmType enumType) + { + ArgumentNotNull(enumType, "enumType"); - public PrimitiveType GetEnumUnderlyingType(EdmType enumType) - { - ArgumentNotNull(enumType, "enumType"); + return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null); + } - return (PrimitiveType) enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null); - } - - public string CreateLiteral(object value) + public string CreateLiteral(object value) + { + if (value == null || value.GetType() != typeof(TimeSpan)) { - if (value == null || value.GetType() != typeof(TimeSpan)) - { - return _code.CreateLiteral(value); - } - - return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan) value).Ticks); + return _code.CreateLiteral(value); } - public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable types, string sourceFile) + return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks); + } + + public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable types, string sourceFile) + { + ArgumentNotNull(types, "types"); + ArgumentNotNull(sourceFile, "sourceFile"); + + var hash = new HashSet(StringComparer.InvariantCultureIgnoreCase); + if (types.Any(item => !hash.Add(item))) { - ArgumentNotNull(types, "types"); - ArgumentNotNull(sourceFile, "sourceFile"); - - var hash = new HashSet(StringComparer.InvariantCultureIgnoreCase); - if (types.Any(item => !hash.Add(item))) - { - _errors.Add( - new CompilerError(sourceFile, -1, -1, "6023", - String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict")))); - return false; - } - return true; + _errors.Add( + new CompilerError(sourceFile, -1, -1, "6023", + String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict")))); + return false; } + return true; + } + + public IEnumerable GetEnumItemsToGenerate(IEnumerable itemCollection) + { + return GetItemsToGenerate(itemCollection) + .Where(e => IsEnumType(e)); + } + + public IEnumerable GetItemsToGenerate(IEnumerable itemCollection) where T: EdmType + { + return itemCollection + .OfType() + .Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName)) + .OrderBy(i => i.Name); + } - public IEnumerable GetEnumItemsToGenerate(IEnumerable itemCollection) - { - return GetItemsToGenerate(itemCollection) - .Where(e => IsEnumType(e)); - } + public IEnumerable GetAllGlobalItems(IEnumerable itemCollection) + { + return itemCollection + .Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i)) + .Select(g => GetGlobalItemName(g)); + } - public IEnumerable GetItemsToGenerate(IEnumerable itemCollection) where T : EdmType + public string GetGlobalItemName(GlobalItem item) + { + if (item is EdmType) { - return itemCollection - .OfType() - .Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName)) - .OrderBy(i => i.Name); + return ((EdmType)item).Name; } - - public IEnumerable GetAllGlobalItems(IEnumerable itemCollection) + else { - return itemCollection - .Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i)) - .Select(g => GetGlobalItemName(g)); + return ((EntityContainer)item).Name; } + } - public string GetGlobalItemName(GlobalItem item) - { - if (item is EdmType) - { - return ((EdmType) item).Name; - } - return ((EntityContainer) item).Name; - } + public IEnumerable GetSimpleProperties(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); + } + + public IEnumerable GetSimpleProperties(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); + } + + public IEnumerable GetComplexProperties(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); + } + + public IEnumerable GetComplexProperties(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); + } - public IEnumerable GetSimpleProperties(EntityType type) - { - return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); - } + public IEnumerable GetPropertiesWithDefaultValues(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); + } + + public IEnumerable GetPropertiesWithDefaultValues(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); + } - public IEnumerable GetSimpleProperties(ComplexType type) - { - return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); - } + public IEnumerable GetNavigationProperties(EntityType type) + { + return type.NavigationProperties.Where(np => np.DeclaringType == type); + } + + public IEnumerable GetCollectionNavigationProperties(EntityType type) + { + return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many); + } + + public FunctionParameter GetReturnParameter(EdmFunction edmFunction) + { + ArgumentNotNull(edmFunction, "edmFunction"); - public IEnumerable GetComplexProperties(EntityType type) - { - return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); - } + var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters"); + return returnParamsProperty == null + ? edmFunction.ReturnParameter + : ((IEnumerable)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault(); + } - public IEnumerable GetComplexProperties(ComplexType type) - { - return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); - } + public bool IsComposable(EdmFunction edmFunction) + { + ArgumentNotNull(edmFunction, "edmFunction"); - public IEnumerable GetPropertiesWithDefaultValues(EntityType type) - { - return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); - } + var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute"); + return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null); + } - public IEnumerable GetPropertiesWithDefaultValues(ComplexType type) - { - return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); - } + public IEnumerable GetParameters(EdmFunction edmFunction) + { + return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef); + } - public IEnumerable GetNavigationProperties(EntityType type) - { - return type.NavigationProperties.Where(np => np.DeclaringType == type); - } - - public IEnumerable GetCollectionNavigationProperties(EntityType type) - { - return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many); - } - - public FunctionParameter GetReturnParameter(EdmFunction edmFunction) - { - ArgumentNotNull(edmFunction, "edmFunction"); - - var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters"); - return returnParamsProperty == null - ? edmFunction.ReturnParameter - : ((IEnumerable) returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault(); - } - - public bool IsComposable(EdmFunction edmFunction) - { - ArgumentNotNull(edmFunction, "edmFunction"); - - var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute"); - return isComposableProperty != null && (bool) isComposableProperty.GetValue(edmFunction, null); - } - - public IEnumerable GetParameters(EdmFunction edmFunction) - { - return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef); - } - - public TypeUsage GetReturnType(EdmFunction edmFunction) - { - var returnParam = GetReturnParameter(edmFunction); - return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage); - } - - public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption) - { - var returnType = GetReturnType(edmFunction); - return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType; - } + public TypeUsage GetReturnType(EdmFunction edmFunction) + { + var returnParam = GetReturnParameter(edmFunction); + return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage); } + + public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption) + { + var returnType = GetReturnType(edmFunction); + return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType; + } +} - public static void ArgumentNotNull(T arg, string name) where T : class +public static void ArgumentNotNull(T arg, string name) where T : class +{ + if (arg == null) { - if (arg == null) - { - throw new ArgumentNullException(name); - } + throw new ArgumentNullException(name); } +} #> \ No newline at end of file Index: Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/RiskeerEntities.Designer.cs =================================================================== diff -u -r2b380c8b1856b5b4212c2ab20bb61a7192cfca52 -rb7c99708b5c1c75e45ebb7b95bec67625b1dd977 --- Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/RiskeerEntities.Designer.cs (.../RiskeerEntities.Designer.cs) (revision 2b380c8b1856b5b4212c2ab20bb61a7192cfca52) +++ Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/RiskeerEntities.Designer.cs (.../RiskeerEntities.Designer.cs) (revision b7c99708b5c1c75e45ebb7b95bec67625b1dd977) @@ -19,7 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -// T4 code generation is enabled for model 'D:\checkouts\Riskeer Additional\tools\StorageEntityGenerator\StorageEntityGenerator\DbContext\RiskeerEntities.edmx'. +// T4 code generation is enabled for model 'C:\SVN_Repos\Riskeer - DB Generator\StorageEntityGenerator\DbContext\RiskeerEntities.edmx'. // To enable legacy code generation, change the value of the 'Code Generation Strategy' designer // property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model // is open in the designer. Index: Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/RiskeerEntities.edmx =================================================================== diff -u -r2b380c8b1856b5b4212c2ab20bb61a7192cfca52 -rb7c99708b5c1c75e45ebb7b95bec67625b1dd977 --- Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/RiskeerEntities.edmx (.../RiskeerEntities.edmx) (revision 2b380c8b1856b5b4212c2ab20bb61a7192cfca52) +++ Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/RiskeerEntities.edmx (.../RiskeerEntities.edmx) (revision b7c99708b5c1c75e45ebb7b95bec67625b1dd977) @@ -4,7 +4,7 @@ - + @@ -13,12 +13,6 @@ - - - - - - @@ -467,12 +461,6 @@ - - - - - - @@ -674,12 +662,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1620,7 +1633,7 @@ - + @@ -1632,78 +1645,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2285,78 +2226,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2572,30 +2441,78 @@ - - - + + + - - + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + + + + + + + + + + + + @@ -3553,7 +3470,10 @@ + + + @@ -3622,30 +3542,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -3839,30 +3735,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -3934,12 +3806,28 @@ - - + + + + + + - + + + + + + + + + + + + + @@ -4292,6 +4180,7 @@ + @@ -4360,30 +4249,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -4396,6 +4261,10 @@ + + + + @@ -4548,7 +4417,7 @@ - + @@ -4756,30 +4625,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -4800,10 +4645,6 @@ - - - - @@ -4960,6 +4801,14 @@ + + + + + + + + @@ -4973,12 +4822,6 @@ - - - - - - @@ -4991,15 +4834,10 @@ - - - - - - + @@ -5315,7 +5153,7 @@ - + @@ -5539,21 +5377,9 @@ - - - - - - - - - - - - - + @@ -5773,26 +5599,25 @@ + + + + + + + + + + + - - - - - - - - - - - - - + @@ -5802,9 +5627,10 @@ - + + @@ -6848,7 +6674,7 @@ - + @@ -6860,78 +6686,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -6972,6 +6726,18 @@ + + + + + + + + + + + + @@ -7428,7 +7194,7 @@ - + @@ -8052,78 +7818,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -8184,18 +7878,6 @@ - - - - - - - - - - - - @@ -8632,6 +8314,14 @@ + + + + + + + + @@ -8654,12 +8344,6 @@ - - - - - - @@ -9099,12 +8783,6 @@ - - - - - - @@ -9319,6 +8997,16 @@ + + + + + + + + + + @@ -10325,6 +10013,22 @@ + + + + + + + + + + + + + + + + Index: Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/RiskeerEntities.edmx.diagram =================================================================== diff -u -r2b380c8b1856b5b4212c2ab20bb61a7192cfca52 -rb7c99708b5c1c75e45ebb7b95bec67625b1dd977 --- Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/RiskeerEntities.edmx.diagram (.../RiskeerEntities.edmx.diagram) (revision 2b380c8b1856b5b4212c2ab20bb61a7192cfca52) +++ Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/RiskeerEntities.edmx.diagram (.../RiskeerEntities.edmx.diagram) (revision b7c99708b5c1c75e45ebb7b95bec67625b1dd977) @@ -52,114 +52,110 @@ - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - - - - - + + + + + - - - - - - + @@ -198,7 +194,7 @@ - + @@ -250,18 +246,11 @@ - - - - - - - @@ -301,6 +290,8 @@ + + Index: Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/RiskeerEntities.tt =================================================================== diff -u -rda1df87d94dcc61aa26d5f033c6bf579c2249cdd -rb7c99708b5c1c75e45ebb7b95bec67625b1dd977 --- Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/RiskeerEntities.tt (.../RiskeerEntities.tt) (revision da1df87d94dcc61aa26d5f033c6bf579c2249cdd) +++ Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/RiskeerEntities.tt (.../RiskeerEntities.tt) (revision b7c99708b5c1c75e45ebb7b95bec67625b1dd977) @@ -1,228 +1,231 @@ <#@ template language="C#" debug="false" hostspecific="true"#> <#@ include file="EF6.Utility.CS.ttinclude"#><#@ - output extension=".cs"#><#@ import namespace="System.Collections" #><# - const string inputFile = @"RiskeerEntities.edmx"; - var textTransform = DynamicTextTransformation.Create(this); - var code = new CodeGenerationTools(this); - var ef = new MetadataTools(this); - var typeMapper = new TypeMapper(code, ef, textTransform.Errors); - var fileManager = EntityFrameworkTemplateFileManager.Create(this); - var itemCollection = new EdmMetadataLoader(textTransform.Host, textTransform.Errors).CreateEdmItemCollection(inputFile); - var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef); + output extension=".cs"#><# - if (!typeMapper.VerifyCaseInsensitiveTypeUniqueness(typeMapper.GetAllGlobalItems(itemCollection), inputFile)) - { - return string.Empty; - } +const string inputFile = @"RiskeerEntities.edmx"; +var textTransform = DynamicTextTransformation.Create(this); +var code = new CodeGenerationTools(this); +var ef = new MetadataTools(this); +var typeMapper = new TypeMapper(code, ef, textTransform.Errors); +var fileManager = EntityFrameworkTemplateFileManager.Create(this); +var itemCollection = new EdmMetadataLoader(textTransform.Host, textTransform.Errors).CreateEdmItemCollection(inputFile); +var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef); - WriteHeader(codeStringGenerator, fileManager); +if (!typeMapper.VerifyCaseInsensitiveTypeUniqueness(typeMapper.GetAllGlobalItems(itemCollection), inputFile)) +{ + return string.Empty; +} - foreach (var entity in typeMapper.GetItemsToGenerate(itemCollection)) - { - fileManager.StartNewFile(entity.Name + ".cs"); - BeginNamespace(code); +WriteHeader(codeStringGenerator, fileManager); + +foreach (var entity in typeMapper.GetItemsToGenerate(itemCollection)) +{ + fileManager.StartNewFile(entity.Name + ".cs"); + BeginNamespace(code); #> -<#= codeStringGenerator.UsingDirectives(inHeader: false) #> -<#= codeStringGenerator.EntityClassOpening(entity) #> +<#=codeStringGenerator.UsingDirectives(inHeader: false)#> +<#=codeStringGenerator.EntityClassOpening(entity)#> { <# - var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(entity); - var collectionNavigationProperties = typeMapper.GetCollectionNavigationProperties(entity); - var complexProperties = typeMapper.GetComplexProperties(entity); + var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(entity); + var collectionNavigationProperties = typeMapper.GetCollectionNavigationProperties(entity); + var complexProperties = typeMapper.GetComplexProperties(entity); - if (propertiesWithDefaultValues.Any() || collectionNavigationProperties.Any() || complexProperties.Any()) - { + if (propertiesWithDefaultValues.Any() || collectionNavigationProperties.Any() || complexProperties.Any()) + { #> [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] - public <#= code.Escape(entity) #>() + public <#=code.Escape(entity)#>() { <# - foreach (var edmProperty in propertiesWithDefaultValues) - { + foreach (var edmProperty in propertiesWithDefaultValues) + { #> - <#= code.Escape(edmProperty) #> = <#= typeMapper.CreateLiteral(edmProperty.DefaultValue) #>; + <#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>; <# - } + } - foreach (var navigationProperty in collectionNavigationProperties) - { + foreach (var navigationProperty in collectionNavigationProperties) + { #> - <#= code.Escape(navigationProperty) #> = new HashSet<<#= typeMapper.GetTypeName(navigationProperty.ToEndMember.GetEntityType()) #>>(); + <#=code.Escape(navigationProperty)#> = new HashSet<<#=typeMapper.GetTypeName(navigationProperty.ToEndMember.GetEntityType())#>>(); <# - } + } - foreach (var complexProperty in complexProperties) - { + foreach (var complexProperty in complexProperties) + { #> - <#= code.Escape(complexProperty) #> = new <#= typeMapper.GetTypeName(complexProperty.TypeUsage) #>(); + <#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>(); <# - } + } #> } <# - } + } - var simpleProperties = typeMapper.GetSimpleProperties(entity); - if (simpleProperties.Any()) + var simpleProperties = typeMapper.GetSimpleProperties(entity); + if (simpleProperties.Any()) + { + foreach (var edmProperty in simpleProperties) { - foreach (var edmProperty in simpleProperties) - { #> - <#= codeStringGenerator.Property(edmProperty) #> + <#=codeStringGenerator.Property(edmProperty)#> <# - } } + } - if (complexProperties.Any()) - { + if (complexProperties.Any()) + { #> <# - foreach (var complexProperty in complexProperties) - { + foreach(var complexProperty in complexProperties) + { #> - <#= codeStringGenerator.Property(complexProperty) #> + <#=codeStringGenerator.Property(complexProperty)#> <# - } } + } - var navigationProperties = typeMapper.GetNavigationProperties(entity); - if (navigationProperties.Any()) - { + var navigationProperties = typeMapper.GetNavigationProperties(entity); + if (navigationProperties.Any()) + { #> <# - foreach (var navigationProperty in navigationProperties) + foreach (var navigationProperty in navigationProperties) + { + if (navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many) { - if (navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many) - { #> [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] <# - } + } #> - <#= codeStringGenerator.NavigationProperty(navigationProperty) #> + <#=codeStringGenerator.NavigationProperty(navigationProperty)#> <# - } } + } #> } <# - EndNamespace(code); - } + EndNamespace(code); +} - foreach (var complex in typeMapper.GetItemsToGenerate(itemCollection)) - { - fileManager.StartNewFile(complex.Name + ".cs"); - BeginNamespace(code); +foreach (var complex in typeMapper.GetItemsToGenerate(itemCollection)) +{ + fileManager.StartNewFile(complex.Name + ".cs"); + BeginNamespace(code); #> -<#= codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false) #> -<#= Accessibility.ForType(complex) #> partial class <#= code.Escape(complex) #> +<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#> +<#=Accessibility.ForType(complex)#> partial class <#=code.Escape(complex)#> { <# - var complexProperties = typeMapper.GetComplexProperties(complex); - var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(complex); + var complexProperties = typeMapper.GetComplexProperties(complex); + var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(complex); - if (propertiesWithDefaultValues.Any() || complexProperties.Any()) - { + if (propertiesWithDefaultValues.Any() || complexProperties.Any()) + { #> - public <#= code.Escape(complex) #>() + public <#=code.Escape(complex)#>() { <# - foreach (var edmProperty in propertiesWithDefaultValues) - { + foreach (var edmProperty in propertiesWithDefaultValues) + { #> - this.<#= code.Escape(edmProperty) #> = <#= typeMapper.CreateLiteral(edmProperty.DefaultValue) #>; + this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>; <# - } + } - foreach (var complexProperty in complexProperties) - { + foreach (var complexProperty in complexProperties) + { #> - this.<#= code.Escape(complexProperty) #> = new <#= typeMapper.GetTypeName(complexProperty.TypeUsage) #>(); + this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>(); <# - } + } #> } <# - } + } - var simpleProperties = typeMapper.GetSimpleProperties(complex); - if (simpleProperties.Any()) + var simpleProperties = typeMapper.GetSimpleProperties(complex); + if (simpleProperties.Any()) + { + foreach(var edmProperty in simpleProperties) { - foreach (var edmProperty in simpleProperties) - { #> - <#= codeStringGenerator.Property(edmProperty) #> + <#=codeStringGenerator.Property(edmProperty)#> <# - } } + } - if (complexProperties.Any()) - { + if (complexProperties.Any()) + { #> <# - foreach (var edmProperty in complexProperties) - { + foreach(var edmProperty in complexProperties) + { #> - <#= codeStringGenerator.Property(edmProperty) #> + <#=codeStringGenerator.Property(edmProperty)#> <# - } } + } #> } <# - EndNamespace(code); - } + EndNamespace(code); +} - foreach (var enumType in typeMapper.GetEnumItemsToGenerate(itemCollection)) - { - fileManager.StartNewFile(enumType.Name + ".cs"); - BeginNamespace(code); +foreach (var enumType in typeMapper.GetEnumItemsToGenerate(itemCollection)) +{ + fileManager.StartNewFile(enumType.Name + ".cs"); + BeginNamespace(code); #> -<#= codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false) #> +<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#> <# - if (typeMapper.EnumIsFlags(enumType)) - { + if (typeMapper.EnumIsFlags(enumType)) + { #> [Flags] <# - } + } #> -<#= codeStringGenerator.EnumOpening(enumType) #> +<#=codeStringGenerator.EnumOpening(enumType)#> { <# - var foundOne = false; - - foreach (MetadataItem member in typeMapper.GetEnumMembers(enumType)) - { - foundOne = true; + var foundOne = false; + + foreach (MetadataItem member in typeMapper.GetEnumMembers(enumType)) + { + foundOne = true; #> - <#= code.Escape(typeMapper.GetEnumMemberName(member)) #> = <#= typeMapper.GetEnumMemberValue(member) #>, + <#=code.Escape(typeMapper.GetEnumMemberName(member))#> = <#=typeMapper.GetEnumMemberValue(member)#>, <# - } + } - if (foundOne) - { - GenerationEnvironment.Remove(GenerationEnvironment.Length - 3, 1); - } + if (foundOne) + { + this.GenerationEnvironment.Remove(this.GenerationEnvironment.Length - 3, 1); + } #> } <# - EndNamespace(code); - } + EndNamespace(code); +} - fileManager.Process(); +fileManager.Process(); + #> <#+ - public void WriteHeader(CodeStringGenerator codeStringGenerator, EntityFrameworkTemplateFileManager fileManager) - { - fileManager.StartHeader(); + +public void WriteHeader(CodeStringGenerator codeStringGenerator, EntityFrameworkTemplateFileManager fileManager) +{ + fileManager.StartHeader(); #> -// Copyright (C) Stichting Deltares 2021. All rights reserved. +// Copyright (C) Stichting Deltares 2019. All rights reserved. // // This file is part of Riskeer. // @@ -245,504 +248,507 @@ //------------------------------------------------------------------------------ // -// <#= CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1") #> +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#> // -// <#= CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2") #> -// <#= CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3") #> +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#> +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#> // //------------------------------------------------------------------------------ -<#= codeStringGenerator.UsingDirectives(inHeader: true) #> +<#=codeStringGenerator.UsingDirectives(inHeader: true)#> <#+ - fileManager.EndBlock(); - } + fileManager.EndBlock(); +} - public void BeginNamespace(CodeGenerationTools code) +public void BeginNamespace(CodeGenerationTools code) +{ + var codeNamespace = code.VsNamespaceSuggestion(); + if (!String.IsNullOrEmpty(codeNamespace)) { - var codeNamespace = code.VsNamespaceSuggestion(); - if (!String.IsNullOrEmpty(codeNamespace)) - { #> -namespace <#= code.EscapeNamespace(codeNamespace) #> +namespace <#=code.EscapeNamespace(codeNamespace)#> { <#+ - PushIndent(" "); - } + PushIndent(" "); } +} - public void EndNamespace(CodeGenerationTools code) +public void EndNamespace(CodeGenerationTools code) +{ + if (!String.IsNullOrEmpty(code.VsNamespaceSuggestion())) { - if (!String.IsNullOrEmpty(code.VsNamespaceSuggestion())) - { - PopIndent(); + PopIndent(); #> } <#+ - } } +} - public const string TemplateId = "CSharp_DbContext_Types_EF6"; +public const string TemplateId = "CSharp_DbContext_Types_EF6"; - public class CodeStringGenerator +public class CodeStringGenerator +{ + private readonly CodeGenerationTools _code; + private readonly TypeMapper _typeMapper; + private readonly MetadataTools _ef; + + public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef) { - private readonly CodeGenerationTools _code; - private readonly TypeMapper _typeMapper; - private readonly MetadataTools _ef; + ArgumentNotNull(code, "code"); + ArgumentNotNull(typeMapper, "typeMapper"); + ArgumentNotNull(ef, "ef"); - public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef) - { - ArgumentNotNull(code, "code"); - ArgumentNotNull(typeMapper, "typeMapper"); - ArgumentNotNull(ef, "ef"); + _code = code; + _typeMapper = typeMapper; + _ef = ef; + } - _code = code; - _typeMapper = typeMapper; - _ef = ef; - } + public string Property(EdmProperty edmProperty) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1} {2} {{ {3}get; {4}set; }}", + Accessibility.ForProperty(edmProperty), + _typeMapper.GetTypeName(edmProperty.TypeUsage), + _code.Escape(edmProperty), + _code.SpaceAfter(Accessibility.ForGetter(edmProperty)), + _code.SpaceAfter(Accessibility.ForSetter(edmProperty))); + } - public string Property(EdmProperty edmProperty) - { - return string.Format( - CultureInfo.InvariantCulture, - "{0} {1} {2} {{ {3}get; {4}set; }}", - Accessibility.ForProperty(edmProperty), - _typeMapper.GetTypeName(edmProperty.TypeUsage), - _code.Escape(edmProperty), - _code.SpaceAfter(Accessibility.ForGetter(edmProperty)), - _code.SpaceAfter(Accessibility.ForSetter(edmProperty))); + public string NavigationProperty(NavigationProperty navProp) + { + var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType()); + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1} {2} {{ {3}get; {4}set; }}", + AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)), + navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType, + _code.Escape(navProp), + _code.SpaceAfter(Accessibility.ForGetter(navProp)), + _code.SpaceAfter(Accessibility.ForSetter(navProp))); + } + + public string AccessibilityAndVirtual(string accessibility) + { + return accessibility + (accessibility != "private" ? " virtual" : ""); + } + + public string EntityClassOpening(EntityType entity) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1}partial class {2}{3}", + Accessibility.ForType(entity), + _code.SpaceAfter(_code.AbstractOption(entity)), + _code.Escape(entity), + _code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType))); + } + + public string EnumOpening(SimpleType enumType) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} enum {1} : {2}", + Accessibility.ForType(enumType), + _code.Escape(enumType), + _code.Escape(_typeMapper.UnderlyingClrType(enumType))); } - - public string NavigationProperty(NavigationProperty navProp) + + public void WriteFunctionParameters(EdmFunction edmFunction, Action writeParameter) + { + var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef); + foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable)) { - var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType()); - return string.Format( - CultureInfo.InvariantCulture, - "{0} {1} {2} {{ {3}get; {4}set; }}", - AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)), - navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType, - _code.Escape(navProp), - _code.SpaceAfter(Accessibility.ForGetter(navProp)), - _code.SpaceAfter(Accessibility.ForSetter(navProp))); + var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null"; + var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")"; + var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))"; + writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit); } + } + + public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace) + { + var parameters = _typeMapper.GetParameters(edmFunction); + + return string.Format( + CultureInfo.InvariantCulture, + "{0} IQueryable<{1}> {2}({3})", + AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)), + _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace), + _code.Escape(edmFunction), + string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray())); + } + + public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace) + { + var parameters = _typeMapper.GetParameters(edmFunction); + + return string.Format( + CultureInfo.InvariantCulture, + "return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});", + _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace), + edmFunction.NamespaceName, + edmFunction.Name, + string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()), + _code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()))); + } + + public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption) + { + var parameters = _typeMapper.GetParameters(edmFunction); + var returnType = _typeMapper.GetReturnType(edmFunction); - public string AccessibilityAndVirtual(string accessibility) + var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()); + if (includeMergeOption) { - return accessibility + (accessibility != "private" ? " virtual" : ""); + paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption"; } - public string EntityClassOpening(EntityType entity) - { - return string.Format( - CultureInfo.InvariantCulture, - "{0} {1}partial class {2}{3}", - Accessibility.ForType(entity), - _code.SpaceAfter(_code.AbstractOption(entity)), - _code.Escape(entity), - _code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType))); - } + return string.Format( + CultureInfo.InvariantCulture, + "{0} {1} {2}({3})", + AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)), + returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">", + _code.Escape(edmFunction), + paramList); + } + + public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption) + { + var parameters = _typeMapper.GetParameters(edmFunction); + var returnType = _typeMapper.GetReturnType(edmFunction); - public string EnumOpening(SimpleType enumType) + var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())); + if (includeMergeOption) { - return string.Format( - CultureInfo.InvariantCulture, - "{0} enum {1} : {2}", - Accessibility.ForType(enumType), - _code.Escape(enumType), - _code.Escape(_typeMapper.UnderlyingClrType(enumType))); + callParams = ", mergeOption" + callParams; } + + return string.Format( + CultureInfo.InvariantCulture, + "return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});", + returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">", + edmFunction.Name, + callParams); + } + + public string DbSet(EntitySet entitySet) + { + return string.Format( + CultureInfo.InvariantCulture, + "{0} virtual DbSet<{1}> {2} {{ get; set; }}", + Accessibility.ForReadOnlyProperty(entitySet), + _typeMapper.GetTypeName(entitySet.ElementType), + _code.Escape(entitySet)); + } - public void WriteFunctionParameters(EdmFunction edmFunction, Action writeParameter) - { - var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef); - foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable)) - { - var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null"; - var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")"; - var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))"; - writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit); - } - } - - public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace) - { - var parameters = _typeMapper.GetParameters(edmFunction); - - return string.Format( + public string UsingDirectives(bool inHeader, bool includeCollections = true) + { + return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion()) + ? string.Format( CultureInfo.InvariantCulture, - "{0} IQueryable<{1}> {2}({3})", - AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)), - _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace), - _code.Escape(edmFunction), - string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray())); - } + "{0}using System;{1}" + + "{2}", + inHeader ? Environment.NewLine : "", + includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "", + inHeader ? "" : Environment.NewLine) + : ""; + } +} - public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace) - { - var parameters = _typeMapper.GetParameters(edmFunction); +public class TypeMapper +{ + private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName"; - return string.Format( - CultureInfo.InvariantCulture, - "return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});", - _typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace), - edmFunction.NamespaceName, - edmFunction.Name, - string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()), - _code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()))); - } + private readonly System.Collections.IList _errors; + private readonly CodeGenerationTools _code; + private readonly MetadataTools _ef; - public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption) - { - var parameters = _typeMapper.GetParameters(edmFunction); - var returnType = _typeMapper.GetReturnType(edmFunction); + public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors) + { + ArgumentNotNull(code, "code"); + ArgumentNotNull(ef, "ef"); + ArgumentNotNull(errors, "errors"); - var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()); - if (includeMergeOption) - { - paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption"; - } + _code = code; + _ef = ef; + _errors = errors; + } - return string.Format( - CultureInfo.InvariantCulture, - "{0} {1} {2}({3})", - AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)), - returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">", - _code.Escape(edmFunction), - paramList); - } + public static string FixNamespaces(string typeName) + { + return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial."); + } - public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption) - { - var parameters = _typeMapper.GetParameters(edmFunction); - var returnType = _typeMapper.GetReturnType(edmFunction); + public string GetTypeName(TypeUsage typeUsage) + { + return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null); + } - var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())); - if (includeMergeOption) - { - callParams = ", mergeOption" + callParams; - } + public string GetTypeName(EdmType edmType) + { + return GetTypeName(edmType, isNullable: null, modelNamespace: null); + } - return string.Format( - CultureInfo.InvariantCulture, - "return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});", - returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">", - edmFunction.Name, - callParams); - } - - public string DbSet(EntitySet entitySet) - { - return string.Format( - CultureInfo.InvariantCulture, - "{0} virtual DbSet<{1}> {2} {{ get; set; }}", - Accessibility.ForReadOnlyProperty(entitySet), - _typeMapper.GetTypeName(entitySet.ElementType), - _code.Escape(entitySet)); - } - - public string UsingDirectives(bool inHeader, bool includeCollections = true) - { - return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion()) - ? string.Format( - CultureInfo.InvariantCulture, - "{0}using System;{1}" + - "{2}", - inHeader ? Environment.NewLine : "", - includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "", - inHeader ? "" : Environment.NewLine) - : ""; - } + public string GetTypeName(TypeUsage typeUsage, string modelNamespace) + { + return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace); } - public class TypeMapper + public string GetTypeName(EdmType edmType, string modelNamespace) { - private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName"; + return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace); + } - private readonly IList _errors; - private readonly CodeGenerationTools _code; - private readonly MetadataTools _ef; - - public TypeMapper(CodeGenerationTools code, MetadataTools ef, IList errors) + public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace) + { + if (edmType == null) { - ArgumentNotNull(code, "code"); - ArgumentNotNull(ef, "ef"); - ArgumentNotNull(errors, "errors"); - - _code = code; - _ef = ef; - _errors = errors; + return null; } - public static string FixNamespaces(string typeName) + var collectionType = edmType as CollectionType; + if (collectionType != null) { - return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial."); + return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace)); } - public string GetTypeName(TypeUsage typeUsage) - { - return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null); - } + var typeName = _code.Escape(edmType.MetadataProperties + .Where(p => p.Name == ExternalTypeNameAttributeName) + .Select(p => (string)p.Value) + .FirstOrDefault()) + ?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ? + _code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) : + _code.Escape(edmType)); - public string GetTypeName(EdmType edmType) + if (edmType is StructuralType) { - return GetTypeName(edmType, isNullable: null, modelNamespace: null); + return typeName; } - public string GetTypeName(TypeUsage typeUsage, string modelNamespace) + if (edmType is SimpleType) { - return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace); - } - - public string GetTypeName(EdmType edmType, string modelNamespace) - { - return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace); - } - - public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace) - { - if (edmType == null) + var clrType = UnderlyingClrType(edmType); + if (!IsEnumType(edmType)) { - return null; + typeName = _code.Escape(clrType); } - var collectionType = edmType as CollectionType; - if (collectionType != null) - { - return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace)); - } + typeName = FixNamespaces(typeName); - var typeName = _code.Escape(edmType.MetadataProperties - .Where(p => p.Name == ExternalTypeNameAttributeName) - .Select(p => (string) p.Value) - .FirstOrDefault()) - ?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ? - _code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) : - _code.Escape(edmType)); - - if (edmType is StructuralType) - { - return typeName; - } - - if (edmType is SimpleType) - { - var clrType = UnderlyingClrType(edmType); - if (!IsEnumType(edmType)) - { - typeName = _code.Escape(clrType); - } - - typeName = FixNamespaces(typeName); - - return clrType.IsValueType && isNullable == true ? - String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) : - typeName; - } - - throw new ArgumentException("edmType"); + return clrType.IsValueType && isNullable == true ? + String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) : + typeName; } - public Type UnderlyingClrType(EdmType edmType) - { - ArgumentNotNull(edmType, "edmType"); + throw new ArgumentException("edmType"); + } + + public Type UnderlyingClrType(EdmType edmType) + { + ArgumentNotNull(edmType, "edmType"); - var primitiveType = edmType as PrimitiveType; - if (primitiveType != null) - { - return primitiveType.ClrEquivalentType; - } - - if (IsEnumType(edmType)) - { - return GetEnumUnderlyingType(edmType).ClrEquivalentType; - } - - return typeof(object); - } - - public object GetEnumMemberValue(MetadataItem enumMember) + var primitiveType = edmType as PrimitiveType; + if (primitiveType != null) { - ArgumentNotNull(enumMember, "enumMember"); - - var valueProperty = enumMember.GetType().GetProperty("Value"); - return valueProperty == null ? null : valueProperty.GetValue(enumMember, null); + return primitiveType.ClrEquivalentType; } - public string GetEnumMemberName(MetadataItem enumMember) + if (IsEnumType(edmType)) { - ArgumentNotNull(enumMember, "enumMember"); - - var nameProperty = enumMember.GetType().GetProperty("Name"); - return nameProperty == null ? null : (string) nameProperty.GetValue(enumMember, null); + return GetEnumUnderlyingType(edmType).ClrEquivalentType; } - public IEnumerable GetEnumMembers(EdmType enumType) - { - ArgumentNotNull(enumType, "enumType"); + return typeof(object); + } + + public object GetEnumMemberValue(MetadataItem enumMember) + { + ArgumentNotNull(enumMember, "enumMember"); + + var valueProperty = enumMember.GetType().GetProperty("Value"); + return valueProperty == null ? null : valueProperty.GetValue(enumMember, null); + } + + public string GetEnumMemberName(MetadataItem enumMember) + { + ArgumentNotNull(enumMember, "enumMember"); + + var nameProperty = enumMember.GetType().GetProperty("Name"); + return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null); + } - var membersProperty = enumType.GetType().GetProperty("Members"); - return membersProperty != null - ? (IEnumerable) membersProperty.GetValue(enumType, null) - : Enumerable.Empty(); - } + public System.Collections.IEnumerable GetEnumMembers(EdmType enumType) + { + ArgumentNotNull(enumType, "enumType"); - public bool EnumIsFlags(EdmType enumType) - { - ArgumentNotNull(enumType, "enumType"); + var membersProperty = enumType.GetType().GetProperty("Members"); + return membersProperty != null + ? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null) + : Enumerable.Empty(); + } + + public bool EnumIsFlags(EdmType enumType) + { + ArgumentNotNull(enumType, "enumType"); + + var isFlagsProperty = enumType.GetType().GetProperty("IsFlags"); + return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null); + } - var isFlagsProperty = enumType.GetType().GetProperty("IsFlags"); - return isFlagsProperty != null && (bool) isFlagsProperty.GetValue(enumType, null); - } + public bool IsEnumType(GlobalItem edmType) + { + ArgumentNotNull(edmType, "edmType"); - public bool IsEnumType(GlobalItem edmType) - { - ArgumentNotNull(edmType, "edmType"); + return edmType.GetType().Name == "EnumType"; + } - return edmType.GetType().Name == "EnumType"; - } + public PrimitiveType GetEnumUnderlyingType(EdmType enumType) + { + ArgumentNotNull(enumType, "enumType"); - public PrimitiveType GetEnumUnderlyingType(EdmType enumType) - { - ArgumentNotNull(enumType, "enumType"); + return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null); + } - return (PrimitiveType) enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null); - } - - public string CreateLiteral(object value) + public string CreateLiteral(object value) + { + if (value == null || value.GetType() != typeof(TimeSpan)) { - if (value == null || value.GetType() != typeof(TimeSpan)) - { - return _code.CreateLiteral(value); - } - - return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan) value).Ticks); + return _code.CreateLiteral(value); } - public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable types, string sourceFile) + return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks); + } + + public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable types, string sourceFile) + { + ArgumentNotNull(types, "types"); + ArgumentNotNull(sourceFile, "sourceFile"); + + var hash = new HashSet(StringComparer.InvariantCultureIgnoreCase); + if (types.Any(item => !hash.Add(item))) { - ArgumentNotNull(types, "types"); - ArgumentNotNull(sourceFile, "sourceFile"); - - var hash = new HashSet(StringComparer.InvariantCultureIgnoreCase); - if (types.Any(item => !hash.Add(item))) - { - _errors.Add( - new CompilerError(sourceFile, -1, -1, "6023", - String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict")))); - return false; - } - return true; + _errors.Add( + new CompilerError(sourceFile, -1, -1, "6023", + String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict")))); + return false; } + return true; + } + + public IEnumerable GetEnumItemsToGenerate(IEnumerable itemCollection) + { + return GetItemsToGenerate(itemCollection) + .Where(e => IsEnumType(e)); + } + + public IEnumerable GetItemsToGenerate(IEnumerable itemCollection) where T: EdmType + { + return itemCollection + .OfType() + .Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName)) + .OrderBy(i => i.Name); + } - public IEnumerable GetEnumItemsToGenerate(IEnumerable itemCollection) - { - return GetItemsToGenerate(itemCollection) - .Where(e => IsEnumType(e)); - } + public IEnumerable GetAllGlobalItems(IEnumerable itemCollection) + { + return itemCollection + .Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i)) + .Select(g => GetGlobalItemName(g)); + } - public IEnumerable GetItemsToGenerate(IEnumerable itemCollection) where T : EdmType + public string GetGlobalItemName(GlobalItem item) + { + if (item is EdmType) { - return itemCollection - .OfType() - .Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName)) - .OrderBy(i => i.Name); + return ((EdmType)item).Name; } - - public IEnumerable GetAllGlobalItems(IEnumerable itemCollection) + else { - return itemCollection - .Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i)) - .Select(g => GetGlobalItemName(g)); + return ((EntityContainer)item).Name; } + } - public string GetGlobalItemName(GlobalItem item) - { - if (item is EdmType) - { - return ((EdmType) item).Name; - } - return ((EntityContainer) item).Name; - } + public IEnumerable GetSimpleProperties(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); + } + + public IEnumerable GetSimpleProperties(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); + } + + public IEnumerable GetComplexProperties(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); + } + + public IEnumerable GetComplexProperties(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); + } - public IEnumerable GetSimpleProperties(EntityType type) - { - return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); - } + public IEnumerable GetPropertiesWithDefaultValues(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); + } + + public IEnumerable GetPropertiesWithDefaultValues(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); + } - public IEnumerable GetSimpleProperties(ComplexType type) - { - return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); - } + public IEnumerable GetNavigationProperties(EntityType type) + { + return type.NavigationProperties.Where(np => np.DeclaringType == type); + } + + public IEnumerable GetCollectionNavigationProperties(EntityType type) + { + return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many); + } + + public FunctionParameter GetReturnParameter(EdmFunction edmFunction) + { + ArgumentNotNull(edmFunction, "edmFunction"); - public IEnumerable GetComplexProperties(EntityType type) - { - return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); - } + var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters"); + return returnParamsProperty == null + ? edmFunction.ReturnParameter + : ((IEnumerable)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault(); + } - public IEnumerable GetComplexProperties(ComplexType type) - { - return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); - } + public bool IsComposable(EdmFunction edmFunction) + { + ArgumentNotNull(edmFunction, "edmFunction"); - public IEnumerable GetPropertiesWithDefaultValues(EntityType type) - { - return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); - } + var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute"); + return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null); + } - public IEnumerable GetPropertiesWithDefaultValues(ComplexType type) - { - return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); - } + public IEnumerable GetParameters(EdmFunction edmFunction) + { + return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef); + } - public IEnumerable GetNavigationProperties(EntityType type) - { - return type.NavigationProperties.Where(np => np.DeclaringType == type); - } - - public IEnumerable GetCollectionNavigationProperties(EntityType type) - { - return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many); - } - - public FunctionParameter GetReturnParameter(EdmFunction edmFunction) - { - ArgumentNotNull(edmFunction, "edmFunction"); - - var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters"); - return returnParamsProperty == null - ? edmFunction.ReturnParameter - : ((IEnumerable) returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault(); - } - - public bool IsComposable(EdmFunction edmFunction) - { - ArgumentNotNull(edmFunction, "edmFunction"); - - var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute"); - return isComposableProperty != null && (bool) isComposableProperty.GetValue(edmFunction, null); - } - - public IEnumerable GetParameters(EdmFunction edmFunction) - { - return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef); - } - - public TypeUsage GetReturnType(EdmFunction edmFunction) - { - var returnParam = GetReturnParameter(edmFunction); - return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage); - } - - public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption) - { - var returnType = GetReturnType(edmFunction); - return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType; - } + public TypeUsage GetReturnType(EdmFunction edmFunction) + { + var returnParam = GetReturnParameter(edmFunction); + return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage); } + + public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption) + { + var returnType = GetReturnType(edmFunction); + return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType; + } +} - public static void ArgumentNotNull(T arg, string name) where T : class +public static void ArgumentNotNull(T arg, string name) where T : class +{ + if (arg == null) { - if (arg == null) - { - throw new ArgumentNullException(name); - } + throw new ArgumentNullException(name); } +} #> \ No newline at end of file Index: Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/StabilityPointStructuresCalculationEntity.cs =================================================================== diff -u -rda1df87d94dcc61aa26d5f033c6bf579c2249cdd -rb7c99708b5c1c75e45ebb7b95bec67625b1dd977 --- Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/StabilityPointStructuresCalculationEntity.cs (.../StabilityPointStructuresCalculationEntity.cs) (revision da1df87d94dcc61aa26d5f033c6bf579c2249cdd) +++ Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/StabilityPointStructuresCalculationEntity.cs (.../StabilityPointStructuresCalculationEntity.cs) (revision b7c99708b5c1c75e45ebb7b95bec67625b1dd977) @@ -49,10 +49,25 @@ public int Order { get; set; } public string Name { get; set; } public string Comments { get; set; } + public byte UseBreakWater { get; set; } + public byte BreakWaterType { get; set; } + public double? BreakWaterHeight { get; set; } + public byte UseForeshore { get; set; } + public double? StructureNormalOrientation { get; set; } + public double? StorageStructureAreaMean { get; set; } + public double? StorageStructureAreaCoefficientOfVariation { get; set; } + public double? AllowedLevelIncreaseStorageMean { get; set; } + public double? AllowedLevelIncreaseStorageStandardDeviation { get; set; } + public double? WidthFlowAperturesMean { get; set; } + public double? WidthFlowAperturesStandardDeviation { get; set; } public double? InsideWaterLevelMean { get; set; } public double? InsideWaterLevelStandardDeviation { get; set; } public double? ThresholdHeightOpenWeirMean { get; set; } public double? ThresholdHeightOpenWeirStandardDeviation { get; set; } + public double? CriticalOvertoppingDischargeMean { get; set; } + public double? CriticalOvertoppingDischargeCoefficientOfVariation { get; set; } + public double? FlowWidthAtBottomProtectionMean { get; set; } + public double? FlowWidthAtBottomProtectionStandardDeviation { get; set; } public double? ConstructiveStrengthLinearLoadModelMean { get; set; } public double? ConstructiveStrengthLinearLoadModelCoefficientOfVariation { get; set; } public double? ConstructiveStrengthQuadraticLoadModelMean { get; set; } @@ -84,37 +99,21 @@ public byte InflowModelType { get; set; } public byte LoadSchematizationType { get; set; } public double? VolumicWeightWater { get; set; } + public double? StormDurationMean { get; set; } public double? FactorStormDurationOpenStructure { get; set; } public double? DrainCoefficientMean { get; set; } public double? DrainCoefficientStandardDeviation { get; set; } + public double FailureProbabilityStructureWithErosion { get; set; } + public byte ShouldIllustrationPointsBeCalculated { get; set; } public byte RelevantForScenario { get; set; } public double ScenarioContribution { get; set; } public virtual CalculationGroupEntity CalculationGroupEntity { get; set; } + public virtual ForeshoreProfileEntity ForeshoreProfileEntity { get; set; } + public virtual HydraulicLocationEntity HydraulicLocationEntity { get; set; } public virtual StabilityPointStructureEntity StabilityPointStructureEntity { get; set; } [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] public virtual ICollection StabilityPointStructuresOutputEntities { get; set; } - - public byte UseBreakWater { get; set; } - public byte BreakWaterType { get; set; } - public double? BreakWaterHeight { get; set; } - public byte UseForeshore { get; set; } - public double? StructureNormalOrientation { get; set; } - public double? StorageStructureAreaMean { get; set; } - public double? StorageStructureAreaCoefficientOfVariation { get; set; } - public double? AllowedLevelIncreaseStorageMean { get; set; } - public double? AllowedLevelIncreaseStorageStandardDeviation { get; set; } - public double? WidthFlowAperturesMean { get; set; } - public double? WidthFlowAperturesStandardDeviation { get; set; } - public double? CriticalOvertoppingDischargeMean { get; set; } - public double? CriticalOvertoppingDischargeCoefficientOfVariation { get; set; } - public double? FlowWidthAtBottomProtectionMean { get; set; } - public double? FlowWidthAtBottomProtectionStandardDeviation { get; set; } - public double? StormDurationMean { get; set; } - public double FailureProbabilityStructureWithErosion { get; set; } - public byte ShouldIllustrationPointsBeCalculated { get; set; } - public virtual ForeshoreProfileEntity ForeshoreProfileEntity { get; set; } - public virtual HydraulicLocationEntity HydraulicLocationEntity { get; set; } } } \ No newline at end of file Index: Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/StabilityPointStructuresOutputEntity.cs =================================================================== diff -u -rda1df87d94dcc61aa26d5f033c6bf579c2249cdd -rb7c99708b5c1c75e45ebb7b95bec67625b1dd977 --- Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/StabilityPointStructuresOutputEntity.cs (.../StabilityPointStructuresOutputEntity.cs) (revision da1df87d94dcc61aa26d5f033c6bf579c2249cdd) +++ Riskeer/Storage/src/Riskeer.Storage.Core/DbContext/StabilityPointStructuresOutputEntity.cs (.../StabilityPointStructuresOutputEntity.cs) (revision b7c99708b5c1c75e45ebb7b95bec67625b1dd977) @@ -35,9 +35,9 @@ public long StabilityPointStructuresOutputEntityId { get; set; } public long StabilityPointStructuresCalculationEntityId { get; set; } public long? GeneralResultFaultTreeIllustrationPointEntityId { get; set; } - public virtual StabilityPointStructuresCalculationEntity StabilityPointStructuresCalculationEntity { get; set; } + public double? Reliability { get; set; } public virtual GeneralResultFaultTreeIllustrationPointEntity GeneralResultFaultTreeIllustrationPointEntity { get; set; } - public double? Reliability { get; set; } + public virtual StabilityPointStructuresCalculationEntity StabilityPointStructuresCalculationEntity { get; set; } } } \ No newline at end of file