public SelectMetadataChangesOperation(List <ColumnMetadata> columnMetadata, OrganizationRequest request, ClientSideMetadataJoinTypes clientSideJoin) { this.Columns = columnMetadata; this.Request = request; _clientSideJoinType = clientSideJoin; }
private void AddJoin(FilteredJoin item, JoinOperator jointype) { this.IsSingleSource = false; // Navigates to the left of the joins to the logical parent. Ensures we deal with parent first. NavigateBinaryJoins(item); // LinkEntity = CreateLinkEntity(item, jointype); int currentFilterIndex = 0; foreach (IVisitableBuilder onFilter in item.OnFilters) { onFilter.Accept(this); currentFilterIndex++; } if (currentFilterIndex != 1) { throw new NotSupportedException("You must use exactly one ON condition in a join. For example: INNER JOIN X ON Y.ID = X.ID is supported, but INNER JOIN X ON Y.ID = X.ID AND Y.NAME = X.NAME is not supported."); } if (EqualToFilter == null) { throw new NotSupportedException("When using an ON condition in a join, only Equal To operator is supported. For example: INNER JOIN X ON Y.ID = X.ID"); } if (jointype == JoinOperator.Inner) { if (item.LeftHand.ToString() == "SQLGeneration.Builders.JoinStart") { var rightTable = item.RightHand.Source as Table; if (rightTable != null) { if (GetTableLogicalEntityName(rightTable) == OneToManyRelationshipMetadadataTableLogicalName) { _ClientSideJoinTypes = _ClientSideJoinTypes | ClientSideMetadataJoinTypes.OneToManyRelationshipInnerJoin; } else if (GetTableLogicalEntityName(rightTable) == ManyToManyRelationshipMetadadataTableLogicalName) { _ClientSideJoinTypes = _ClientSideJoinTypes | ClientSideMetadataJoinTypes.ManyToManyRelationshipInnerJoin; } } } //TODO THIS IS WRONG AS NEED TO CHECK THIS IS AN INNER JOIN FROM ENTITYMETADATA TO ONETOMANYRELATIONSHIP } //if (!QueryExpression.LinkEntities.Any()) //{ //if (QueryExpression.EntityName != LinkEntity.LinkFromEntityName) //{ // throw new InvalidOperationException("The first JOIN in the query must link from the main entity which in your case is " + // QueryExpression.EntityName + " but the first join in your query links from: " + // LinkEntity.LinkFromEntityName + " which is an unknown entity,"); //} //QueryExpression.LinkEntities.Add(LinkEntity); // } // else // { //bool isAliased = !string.IsNullOrEmpty(LeftColumn.Source.Alias); //var match = string.IsNullOrEmpty(LeftColumn.Source.Alias) // ? LinkEntity.LinkFromEntityName // : LeftColumn.Source.Alias; //var leftLink = QueryExpression.FindLinkEntity(match, isAliased); //if (leftLink == null) //{ // throw new InvalidOperationException("Could not perform join, as " + match + " is an unknown entity."); //} //leftLink.LinkEntities.Add(LinkEntity); // } // LinkEntity = null; EqualToFilter = null; LeftColumn = null; RightColumn = null; LeftTable = null; RightTable = null; }
public SelectMetadataChangesOperation(List<ColumnMetadata> columnMetadata, OrganizationRequest request, ClientSideMetadataJoinTypes clientSideJoin) { this.Columns = columnMetadata; this.Request = request; _clientSideJoinType = clientSideJoin; }