private static bool HasQueryView(StorageEntityContainerMapping storageEntityContainerMapping) { foreach (EntitySetBase extent in storageEntityContainerMapping.EdmEntityContainer.BaseEntitySets) { if (storageEntityContainerMapping.HasQueryViewForSetMap(extent.Name)) { return(true); } } return(false); }
private static bool HasQueryView(StorageEntityContainerMapping storageEntityContainerMapping) { foreach (EntitySetBase extent in storageEntityContainerMapping.EdmEntityContainer.BaseEntitySets) { if (storageEntityContainerMapping.HasQueryViewForSetMap(extent.Name)) { return true; } } return false; }
// effects: Given a container, ensures that all entity/association // sets in container on the C-side have been mapped private static ErrorLog EnsureAllCSpaceContainerSetsAreMapped(IEnumerable<Cell> cells, ConfigViewGenerator config, StorageEntityContainerMapping containerMapping) { Set<EntitySetBase> mappedExtents = new Set<EntitySetBase>(); string mslFileLocation = null; EntityContainer container = null; // Determine the container and name of the file while determining // the set of mapped extents in the cells foreach (Cell cell in cells) { mappedExtents.Add(cell.CQuery.Extent); mslFileLocation = cell.CellLabel.SourceLocation; // All cells are from the same container container = cell.CQuery.Extent.EntityContainer; } Debug.Assert(container != null); List<EntitySetBase> missingExtents = new List<EntitySetBase>(); // Go through all the extents in the container and determine // extents that are missing foreach (EntitySetBase extent in container.BaseEntitySets) { if (mappedExtents.Contains(extent) == false && !(containerMapping.HasQueryViewForSetMap(extent.Name))) { AssociationSet associationSet = extent as AssociationSet; if (associationSet==null || !associationSet.ElementType.IsForeignKey) { missingExtents.Add(extent); } } } ErrorLog errorLog = new ErrorLog(); // If any extent is not mapped, add an error if (missingExtents.Count > 0) { StringBuilder extentBuilder = new StringBuilder(); bool isFirst = true; foreach (EntitySetBase extent in missingExtents) { if (isFirst == false) { extentBuilder.Append(", "); } isFirst = false; extentBuilder.Append(extent.Name); } string message = System.Data.Entity.Strings.ViewGen_Missing_Set_Mapping(extentBuilder); // Find the cell with smallest line number - so that we can // point to the beginning of the file int lowestLineNum = -1; Cell smallestCell = null; foreach (Cell cell in cells) { if (lowestLineNum == -1 || cell.CellLabel.StartLineNumber < lowestLineNum) { smallestCell = cell; lowestLineNum = cell.CellLabel.StartLineNumber; } } Debug.Assert(smallestCell != null && lowestLineNum >= 0); EdmSchemaError edmSchemaError = new EdmSchemaError(message, (int)ViewGenErrorCode.MissingExtentMapping, EdmSchemaErrorSeverity.Error, containerMapping.SourceLocation, containerMapping.StartLineNumber, containerMapping.StartLinePosition, null); ErrorLog.Record record = new ErrorLog.Record(edmSchemaError); errorLog.AddEntry(record); } return errorLog; }
// effects: Given a container, ensures that all entity/association // sets in container on the C-side have been mapped private static ErrorLog EnsureAllCSpaceContainerSetsAreMapped( IEnumerable <Cell> cells, StorageEntityContainerMapping containerMapping) { var mappedExtents = new Set <EntitySetBase>(); string mslFileLocation = null; EntityContainer container = null; // Determine the container and name of the file while determining // the set of mapped extents in the cells foreach (var cell in cells) { mappedExtents.Add(cell.CQuery.Extent); mslFileLocation = cell.CellLabel.SourceLocation; // All cells are from the same container container = cell.CQuery.Extent.EntityContainer; } Debug.Assert(container != null); var missingExtents = new List <EntitySetBase>(); // Go through all the extents in the container and determine // extents that are missing foreach (var extent in container.BaseEntitySets) { if (mappedExtents.Contains(extent) == false && !(containerMapping.HasQueryViewForSetMap(extent.Name))) { var associationSet = extent as AssociationSet; if (associationSet == null || !associationSet.ElementType.IsForeignKey) { missingExtents.Add(extent); } } } var errorLog = new ErrorLog(); // If any extent is not mapped, add an error if (missingExtents.Count > 0) { var extentBuilder = new StringBuilder(); var isFirst = true; foreach (var extent in missingExtents) { if (isFirst == false) { extentBuilder.Append(", "); } isFirst = false; extentBuilder.Append(extent.Name); } var message = Strings.ViewGen_Missing_Set_Mapping(extentBuilder); // Find the cell with smallest line number - so that we can // point to the beginning of the file var lowestLineNum = -1; Cell smallestCell = null; foreach (var cell in cells) { if (lowestLineNum == -1 || cell.CellLabel.StartLineNumber < lowestLineNum) { smallestCell = cell; lowestLineNum = cell.CellLabel.StartLineNumber; } } Debug.Assert(smallestCell != null && lowestLineNum >= 0); var edmSchemaError = new EdmSchemaError( message, (int)ViewGenErrorCode.MissingExtentMapping, EdmSchemaErrorSeverity.Error, containerMapping.SourceLocation, containerMapping.StartLineNumber, containerMapping.StartLinePosition, null); var record = new ErrorLog.Record(edmSchemaError); errorLog.AddEntry(record); } return(errorLog); }