internal static void GenerateEntitySetViews( StorageEntityContainerMapping entityContainerMapping, Dictionary<EntitySetBase, string> esqlViews, IList<EdmSchemaError> errors) { Debug.Assert(entityContainerMapping.HasViews); // If entityContainerMapping contains only query views, then add a warning to the errors and continue to next mapping. if (!entityContainerMapping.HasMappingFragments()) { Debug.Assert( 2088 == (int)StorageMappingErrorCode.MappingAllQueryViewAtCompileTime, "Please change the ERRORCODE_MAPPINGALLQUERYVIEWATCOMPILETIME value as well"); errors.Add( new EdmSchemaError( Strings.Mapping_AllQueryViewAtCompileTime(entityContainerMapping.Identity), (int)StorageMappingErrorCode.MappingAllQueryViewAtCompileTime, EdmSchemaErrorSeverity.Warning)); } else { var viewGenResults = ViewgenGatekeeper.GenerateViewsFromMapping( entityContainerMapping, new ConfigViewGenerator { GenerateEsql = true }); if (viewGenResults.HasErrors) { ((List<EdmSchemaError>)errors).AddRange(viewGenResults.Errors); } var extentMappingViews = viewGenResults.Views; foreach (var extentViewPair in extentMappingViews.KeyValuePairs) { var generatedViews = extentViewPair.Value; // Multiple Views are returned for an extent but the first view // is the only one that we will use for now. In the future, // we might start using the other views which are per type within an extent. esqlViews.Add(extentViewPair.Key, generatedViews[0].eSQL); } } }
internal static Dictionary<EntitySetBase, DbMappingView> GenerateViews( StorageEntityContainerMapping containerMapping, IList<EdmSchemaError> errors) { var views = new Dictionary<EntitySetBase, DbMappingView>(); if (!containerMapping.HasViews) { return views; } // If the entity container mapping has only query views, add a warning and return. if (!containerMapping.HasMappingFragments()) { Debug.Assert( 2088 == (int)StorageMappingErrorCode.MappingAllQueryViewAtCompileTime, "Please change the ERRORCODE_MAPPINGALLQUERYVIEWATCOMPILETIME value as well."); errors.Add( new EdmSchemaError( Strings.Mapping_AllQueryViewAtCompileTime(containerMapping.Identity), (int)StorageMappingErrorCode.MappingAllQueryViewAtCompileTime, EdmSchemaErrorSeverity.Warning)); return views; } var viewGenResults = ViewgenGatekeeper.GenerateViewsFromMapping( containerMapping, new ConfigViewGenerator { GenerateEsql = true }); if (viewGenResults.HasErrors) { viewGenResults.Errors.Each(e => errors.Add(e)); } foreach (var extentViewPair in viewGenResults.Views.KeyValuePairs) { // Multiple views are returned for an extent but the first view is // the only one that we will use for now. In the future, we might // start using the other views which are per type within an extent. views.Add(extentViewPair.Key, new DbMappingView(extentViewPair.Value[0].eSQL)); } return views; }