public static JoinModel getJoinModel(JoinOperator jo, string tableName1, string tableName2, string joinQuery) { JoinModel jm = new JoinModel(); jm.JoinOperator = jo; jm.TableName1 = tableName1; jm.TableName2 = tableName2; jm.JoinQuery = joinQuery.Replace("'", "''"); return jm; }
public static string getJoinOperator(JoinOperator jo, string tableName1,string tableName2,string joinQuery) { string opt = ""; switch (jo) { case JoinOperator.Left: opt = tableName1+" left join " + tableName2 + " on " + joinQuery; break; case JoinOperator.Right: opt = tableName1+" right join " + tableName2 + " on " + joinQuery; break; case JoinOperator.Inner: opt = tableName1+" inner join " + tableName2 + " on " + joinQuery; break; case JoinOperator.LOuter: opt = tableName1 + " left outer join " + tableName2 + " on " + joinQuery; break; case JoinOperator.ROuter: opt = tableName1 + " right outer join " + tableName2 + " on " + joinQuery; break; } return opt; }
/// <summary> /// Adds the type T as a linked entity, additionally ensuring it is active. /// Assumes both entities have the same attribute name to link on. /// </summary> /// <typeparam name="T">The type of the entity that is to be linked and asserted active.</typeparam> /// <param name="qe">The query expression.</param> /// <param name="linkAttributesName">Name of the link attributes.</param> /// <param name="joinType">Type of the join to perform.</param> /// <param name="anonymousTypeInitializer">An Anonymous Type Initializer where the properties of the anonymous /// type are the column names to add</param> /// <returns></returns> public static LinkEntity AddLink <T>(this QueryExpression qe, string linkAttributesName, JoinOperator joinType, Expression <Func <T, object> > anonymousTypeInitializer) where T : Entity { return(qe.AddLink(linkAttributesName, linkAttributesName, joinType, anonymousTypeInitializer)); }
/// <summary> /// Adds the type T as a linked entity, additionally ensuring it is active. /// </summary> /// <typeparam name="T">The type of the entity that is to be linked and asserted active.</typeparam> /// <param name="qe">The query expression.</param> /// <param name="linkFromAttributeName">Name of the link from attribute.</param> /// <param name="linkToAttributeName">Name of the link to attribute.</param> /// <param name="joinType">Type of the join to perform.</param> /// <param name="anonymousTypeInitializer">An Anonymous Type Initializer where the properties of the anonymous /// type are the column names to add</param> /// <returns></returns> public static LinkEntity AddLink <T>(this QueryExpression qe, string linkFromAttributeName, string linkToAttributeName, JoinOperator joinType, Expression <Func <T, object> > anonymousTypeInitializer) where T : Entity { var link = qe.AddLink(EntityHelper.GetEntityLogicalName <T>(), linkFromAttributeName, linkToAttributeName, joinType); if (_activeOnly) { link.LinkCriteria.ActiveOnly <T>(); } link.Columns.AddColumns(anonymousTypeInitializer); return(link); }
/// <summary> /// Adds the type T as a child linked entity, additionally ensuring it is active. /// </summary> /// <typeparam name="T">The type of Entity</typeparam> /// <param name="link">The link.</param> /// <param name="linkFromAttributeName">Name of the link from attribute.</param> /// <param name="linkToAttributeName">Name of the link to attribute.</param> /// <param name="joinType">Type of the join.</param> /// <returns></returns> public static LinkEntity AddLink <T>(this LinkEntity link, string linkFromAttributeName, string linkToAttributeName, JoinOperator joinType) where T : Entity { var childLink = link.AddChildLink(EntityHelper.GetEntityLogicalName <T>(), linkFromAttributeName, linkToAttributeName, joinType); if (_activeOnly) { childLink.LinkCriteria.ActiveOnly <T>(); } return(childLink); }
/// <summary> /// Adds a LinkEntity to the Query Expression, returning it. /// </summary> /// <param name="qe">The qe.</param> /// <param name="linkToEntityName">Name of the link to entity.</param> /// <param name="linkAttributesName">Name of the link attributes.</param> /// <param name="joinType">Type of the join.</param> /// <returns></returns> public static LinkEntity AddLink(this QueryExpression qe, string linkToEntityName, string linkAttributesName, JoinOperator joinType) { return(qe.AddLink(linkToEntityName, linkAttributesName, linkAttributesName, joinType)); }
/// <summary> /// Adds the type T as a linked entity, additionally ensuring it is active. /// </summary> /// <typeparam name="T">The type of the entity that is to be linked and asserted active.</typeparam> /// <param name="linkFromAttributeName">Name of the link from attribute.</param> /// <param name="linkToAttributeName">Name of the link to attribute.</param> /// <param name="joinType">Type of the join to perform.</param> /// <returns></returns> public LinkEntity AddLink <T>(string linkFromAttributeName, string linkToAttributeName, JoinOperator joinType) where T : Entity { return(Query.AddLink <T>(linkFromAttributeName, linkToAttributeName, joinType)); }
/// <summary> /// Initializes the operator resolver. /// </summary> /// <returns>The operator resolver.</returns> private static OperatorResolver InitOperatorResolver() { Mock <OperatorResolver> opResolverMock = new Mock <OperatorResolver>(); IExpressionFactory exprFactory = new ExpressionFactory( ModelResolvers.ExprResolver, ModelResolvers.RuleExprResolver, ModelResolvers.JoinExprResolver, opResolverMock.Object); JoinApplyMeasuresOperator joinApplyMeasuresOp = new JoinApplyMeasuresOperator( exprFactory, ModelResolvers.DsResolver); opResolverMock.Setup(o => o(It.IsAny <string>())) .Returns((string key) => { IOperatorDefinition op; if (key.In("count", "min", "max", "median", "sum", "avg", "stddev_pop", "stddev_samp", "var_pop", "var_samp")) { op = new AggrFunctionOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key == "aggr") { op = new AggrOperator(); } else if (key.In("first_value", "last_value", "lag", "rank", "ratio_to_report", "lead")) { op = new AnalyticFunctionOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key.In("+", "-", "*", "/")) { op = new ArithmeticOperator(joinApplyMeasuresOp); } else if (key == "between") { op = new BetweenOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key.In("and", "or", "xor", "not")) { op = new BooleanOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key == "calc") { op = new CalcOperator(ModelResolvers.DsResolver); } else if (key == "check_datapoint") { op = new CheckDatapointOperator(ModelResolvers.DsResolver, exprFactory); } else if (key.In("=", "<>", "<", "<=", ">", ">=")) { op = new ComparisonOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key == "comp") { op = new ComponentOperator(ModelResolvers.DsResolver, new ComponentTypeInference(ModelResolvers.DsResolver)); } else if (key == "const") { op = new ConstantOperator(ModelResolvers.DsResolver); } else if (key == "current_date") { op = new CurrentDateOperator(ModelResolvers.DsResolver); } else if (key == "exists_in") { op = new ExistsInOperator(ModelResolvers.DsResolver); } else if (key == "get") { op = new GetOperator(new Mock <IDataModelProvider>().Object); // operator tests should mock IDataModel implementation } else if (key == "if") { op = new IfThenElseOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key.In("in", "not_in")) { op = new InOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key == "isnull") { op = new IsNullOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key == "join") { op = new JoinOperator(ModelResolvers.DsResolver); } else if (key.In("keep", "drop")) { op = new KeepDropOperator(ModelResolvers.DsResolver); } else if (key == "match_characters") { op = new MatchCharactersOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key == "#") { op = new MembershipOperator(); } else if (key.In("ceil", "floor", "abs", "exp", "ln", "sqrt", "mod", "round", "power", "log", "trunc")) { op = new NumericOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key == "nvl") { op = new NvlOperator(joinApplyMeasuresOp); } else if (key == "opt") { op = new OptionalOperator(ModelResolvers.DsResolver); } else if (key == "period_indicator") { op = new PeriodIndicatorOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver, exprFactory); } else if (key == "pivot") { op = new PivotOperator(ModelResolvers.DsResolver); } else if (key == "ref") { op = new ReferenceOperator(); } else if (key == "rename") { op = new RenameOperator(ModelResolvers.DsResolver); } else if (key.In("union", "intersect", "setdiff", "symdiff")) { op = new SetOperator(); } else if (key.In("||", "trim", "rtrim", "ltrim", "upper", "lower", "substr", "replace", "instr", "length")) { op = new StringOperator(joinApplyMeasuresOp, ModelResolvers.DsResolver); } else if (key == "sub") { op = new SubspaceOperator(ModelResolvers.DsResolver); } else if (key.In("fill_time_series", "flow_to_stock", "stock_to_flow", "timeshift", "time_agg")) { op = new TimeOperator(); } else if (key.In("plus", "minus")) { op = new UnaryArithmeticOperator(joinApplyMeasuresOp); } else if (key == "unpivot") { op = new UnpivotOperator(ModelResolvers.DsResolver); } // --- else if (key == "calcExpr") { op = new CalcExprOperator(ModelResolvers.DsResolver); } else if (key == "collection") { op = new CollectionOperator(ModelResolvers.DsResolver); } else if (key == "datasetClause") { op = new DatasetClauseOperator(); } else if (key == "group") { op = new GroupOperator(ModelResolvers.DsResolver); } else if (key == "order") { op = new OrderOperator(ModelResolvers.DsResolver); } else if (key == "partition") { op = new PartitionOperator(ModelResolvers.DsResolver); } else if (key == "renameExpr") { op = new RenameExprOperator(ModelResolvers.DsResolver); } else if (key == "subExpr") { op = new SubspaceExprOperator(); } else if (key == "when") { op = new WhenOperator(); } else { throw new InvalidOperationException("Operator not found"); } op.Symbol = key; return(op); }); return(opResolverMock.Object); }
public LinkEntity(string linkFromEntityName, string linkToEntityName, string linkFromAttributeName, string linkToAttributeName, JoinOperator joinOperator) { this._entityAlias = "LE_" + Guid.NewGuid().ToString("N"); this._linkFromEntityName = linkFromEntityName; this._linkToEntityName = linkToEntityName; this._linkFromAttributeName = linkFromAttributeName; this._linkToAttributeName = linkToAttributeName; this._joinOperator = joinOperator; this._columns = new ColumnSet(); this._linkCriteria = new FilterExpression(); }
/// <summary> /// Adds the link. /// </summary> /// <param name="linkToEntityName">Name of the link to entity.</param> /// <param name="linkFromAttributeName">Name of the link from attribute.</param> /// <param name="linkToAttributeName">Name of the link to attribute.</param> /// <param name="joinOperator">The join operator.</param> /// <returns></returns> public LinkEntity AddLink(string linkToEntityName, string linkFromAttributeName, string linkToAttributeName, JoinOperator joinOperator) { return(Query.AddLink(linkToEntityName, linkFromAttributeName, linkToAttributeName, joinOperator)); }
public void SwapSides() { ExpressionNode oldLeftExpression = _leftExpression; TableRefBinding oldLeftTable = _leftTable; _op = SwapJoinOperator(_op); _leftExpression = _rightExpression; _leftTable = _rightTable; _rightExpression = oldLeftExpression; _rightTable = oldLeftTable; }
public DatabaseJoinOperator(JoinOperator joinOperator) { DependentJoinOperator = ServiceLocator.Instance.Database.GetJoinOperator(joinOperator); }
private static JoinOperator SwapJoinOperator(JoinOperator joinOperator) { switch (joinOperator) { case JoinOperator.None: case JoinOperator.Equal: return joinOperator; case JoinOperator.Less: return JoinOperator.Greater; case JoinOperator.LessOrEqual: return JoinOperator.GreaterOrEqual; case JoinOperator.Greater: return JoinOperator.Less; case JoinOperator.GreaterOrEqual: return JoinOperator.LessOrEqual; default: throw ExceptionBuilder.UnhandledCaseLabel(joinOperator); } }
public Join(string tableName, string aliasName, JoinOperator join) { m_TableName = tableName; m_AliasName = aliasName; m_Join = join; }
public IJoin AddJoins(Type classType, JoinOperator joinOperator) => this.AddJoins(classType, null, joinOperator);
public JoinStatement(ISource source, ICondition condition, JoinOperator joinOperator = JoinOperator.Inner) : base(source) { JoinOperator = joinOperator; Condition = condition; }
/// <summary> /// Add a join query /// </summary> /// <param name="joinFields">Join fields</param> /// <param name="joinType">Join type</param> /// <param name="joinOperator">Join operator</param> /// <param name="joinQuery">Join query</param> /// <returns>Return the newest IQuery object</returns> public IQuery Join(Dictionary <string, string> joinFields, JoinType joinType, JoinOperator joinOperator, IQuery joinQuery) { if (joinQuery.GetEntityType() == null) { throw new EZNEWException("the IQuery object used for the join operation must set the property EntityType"); } return(Join(new JoinItem() { JoinType = joinType, Operator = joinOperator, JoinFields = joinFields, JoinQuery = joinQuery, Sort = joinSort++ })); }
public Link(string toEntity, string toAttribute, string fromAttribute, JoinOperator joinOperator = JoinOperator.Inner) : base(toEntity, toAttribute, fromAttribute, joinOperator) { ToEntity = toEntity; }
/// <summary> /// 设置关联查询 /// </summary> /// <typeparam name="T"></typeparam> /// <typeparam name="T2"></typeparam> /// <param name="expression"></param> /// <param name="op"></param> /// <param name="expression2"></param> /// <param name="join"></param> /// <param name="not"></param> /// <returns></returns> public static IJoinPredicate Join <T, T2>(Expression <Func <T, object> > expression, Operator op, Expression <Func <T2, object> > expression2, JoinOperator join = JoinOperator.Inner, string tableName = null, string tableName2 = null, string schemaName = null, string schemaName2 = null, bool not = false) where T : class where T2 : class { PropertyInfo propertyInfo = ReflectionHelper.GetProperty(expression) as PropertyInfo; PropertyInfo propertyInfo2 = ReflectionHelper.GetProperty(expression2) as PropertyInfo; return(new JoinPredicate <T, T2> { SchemaName = schemaName, TableName = tableName, SchemaName2 = schemaName2, TableName2 = tableName2, Join = join, PropertyName = propertyInfo.Name, PropertyName2 = propertyInfo2.Name, Operator = op, Not = not }); }
public LinkEntity AddLink(string linkToEntityName, string linkFromAttributeName, string linkToAttributeName, JoinOperator joinOperator) { LinkEntity linkEntity = new LinkEntity(this._linkFromEntityName, linkToEntityName, linkFromAttributeName, linkToAttributeName, joinOperator); this.LinkEntities.Add(linkEntity); return(linkEntity); }
public void SwapSides() { AlgebraNode oldLeft = _left; _left = _right; _right = oldLeft; switch (_op) { case JoinOperator.LeftOuterJoin: _op = JoinOperator.RightOuterJoin; break; case JoinOperator.LeftSemiJoin: _op = JoinOperator.RightSemiJoin; break; case JoinOperator.LeftAntiSemiJoin: _op = JoinOperator.RightAntiSemiJoin; break; case JoinOperator.RightOuterJoin: _op = JoinOperator.LeftOuterJoin; break; case JoinOperator.RightSemiJoin: _op = JoinOperator.LeftSemiJoin; break; case JoinOperator.RightAntiSemiJoin: _op = JoinOperator.LeftAntiSemiJoin; break; case JoinOperator.InnerJoin: case JoinOperator.FullOuterJoin: // Nothing to do. break; default: throw ExceptionBuilder.UnhandledCaseLabel(_op); } }
/// <summary> /// Adds the link. /// </summary> /// <param name="linkToEntityName">Name of the link to entity.</param> /// <param name="linkAttributesName">Name of the link attributes.</param> /// <param name="joinType">Type of the join.</param> /// <returns></returns> public LinkEntity AddLink(string linkToEntityName, string linkAttributesName, JoinOperator joinType) { return(Query.AddLink(linkToEntityName, linkAttributesName, linkAttributesName, joinType)); }
/// <summary> /// Add a inner join query /// </summary> /// <param name="sourceQuery">Source query</param> /// <param name="sourceField">Source field</param> /// <param name="targetField">Target field</param> /// <param name="joinOperator">Join operator</param> /// <param name="joinQuery">Join query</param> /// <returns>Return the newest IQuery object</returns> public static IQuery InnerJoin(this IQuery sourceQuery, string sourceField, string targetField, JoinOperator joinOperator, IQuery joinQuery) { return(sourceQuery.Join(sourceField, targetField, JoinType.InnerJoin, joinOperator, joinQuery)); }
/// <summary> /// Adds the type T as a linked entity, additionally ensuring it is active. /// </summary> /// <typeparam name="T">The type of the entity that is to be linked and asserted active.</typeparam> /// <param name="linkFromAttributeName">Name of the link from attribute.</param> /// <param name="linkToAttributeName">Name of the link to attribute.</param> /// <param name="joinType">Type of the join to perform.</param> /// <param name="anonymousTypeInitializer">An Anonymous Type Initializer where the properties of the anonymous /// type are the column names to add</param> /// <returns></returns> public LinkEntity AddLink <T>(string linkFromAttributeName, string linkToAttributeName, JoinOperator joinType, Expression <Func <T, object> > anonymousTypeInitializer) where T : Entity { return(Query.AddLink(linkFromAttributeName, linkToAttributeName, joinType, anonymousTypeInitializer)); }
/// <summary> /// Add a inner join query /// </summary> /// <param name="sourceQuery">Source query</param> /// <param name="joinField">Join field</param> /// <param name="joinOperator">Join operator</param> /// <param name="joinQuery">Join query</param> /// <returns>Return the newest IQuery object</returns> public static IQuery InnerJoin(this IQuery sourceQuery, string joinField, JoinOperator joinOperator, IQuery joinQuery) { return(InnerJoin(sourceQuery, joinField, joinField, joinOperator, joinQuery)); }
/// <summary> /// Adds the type T as a child linked entity, additionally ensuring it is active. /// Assumes both entities have the same attribute name to link on. /// </summary> /// <typeparam name="T">The type of the entity that is to me linked</typeparam> /// <param name="link">The link.</param> /// <param name="linkAttributesName">Name of the link from and link to attribute.</param> /// <param name="joinType">Type of the join to perform.</param> /// <returns></returns> public static LinkEntity AddLink <T>(this LinkEntity link, string linkAttributesName, JoinOperator joinType) where T : Entity { return(link.AddLink <T>(linkAttributesName, linkAttributesName, joinType)); }
/// <summary> /// Add a inner join query /// </summary> /// <typeparam name="TSource">Join source type</typeparam> /// <typeparam name="TTarget">Join target type</typeparam> /// <param name="sourceQuery">Source query</param> /// <param name="sourceField">Source field</param> /// <param name="targetField">Target field</param> /// <param name="joinOperator">Join operator</param> /// <param name="joinQuery">Join query</param> /// <returns>Return the newest IQuery object</returns> public static IQuery InnerJoin <TSource, TTarget>(this IQuery sourceQuery, Expression <Func <TSource, dynamic> > sourceField, Expression <Func <TTarget, dynamic> > targetField, JoinOperator joinOperator, IQuery joinQuery) { var sourceFieldName = ExpressionHelper.GetExpressionPropertyName(sourceField); var targetFieldName = ExpressionHelper.GetExpressionPropertyName(targetField); return(InnerJoin(sourceQuery, sourceFieldName, targetFieldName, joinOperator, joinQuery)); }
/// <summary> /// Adds the type T as a child linked entity, additionally ensuring it is active. /// </summary> /// <typeparam name="T">The type of Entity</typeparam> /// <param name="link">The link.</param> /// <param name="linkFromAttributeName">Name of the link from attribute.</param> /// <param name="linkToAttributeName">Name of the link to attribute.</param> /// <param name="joinType">Type of the join.</param> /// <param name="anonymousTypeInitializer">An Anonymous Type Initializer where the properties of the anonymous /// type are the column names to add</param> /// <returns></returns> public static LinkEntity AddLink <T>(this LinkEntity link, string linkFromAttributeName, string linkToAttributeName, JoinOperator joinType, Expression <Func <T, object> > anonymousTypeInitializer) where T : Entity { var childLink = link.AddLink <T>(linkFromAttributeName, linkToAttributeName, joinType); childLink.Columns.AddColumns(anonymousTypeInitializer); return(childLink); }
/// <summary> /// Add a inner join query /// </summary> /// <typeparam name="TSource">Join source type</typeparam> /// <param name="sourceQuery">Source query</param> /// <param name="joinField">Join field</param> /// <param name="joinOperator">Join operator</param> /// <param name="joinQuery">Join query</param> /// <returns>Return the newest IQuery object</returns> public static IQuery InnerJoin <TSource>(this IQuery sourceQuery, Expression <Func <TSource, dynamic> > joinField, JoinOperator joinOperator, IQuery joinQuery) { var joinFieldName = ExpressionHelper.GetExpressionPropertyName(joinField); return(InnerJoin(sourceQuery, joinFieldName, joinFieldName, joinOperator, joinQuery)); }
/// <summary> /// Adds the type T as a linked entity, additionally ensuring it is active. /// Assumes both entities have the same attribute name to link on. /// </summary> /// <typeparam name="T">The type of the entity that is to be linked and asserted active.</typeparam> /// <param name="qe">The query expression.</param> /// <param name="linkAttributesName">Name of the link attributes.</param> /// <param name="joinType">Type of the join to perform.</param> /// <returns></returns> public static LinkEntity AddLink <T>(this QueryExpression qe, string linkAttributesName, JoinOperator joinType) where T : Entity { return(qe.AddLink <T>(linkAttributesName, linkAttributesName, joinType)); }
/// <summary> /// Adds the new LinkEntity as a child to this LinkEnity, rather than this LinkEntity's LinkFrom Entity /// </summary> /// <param name="link"></param> /// <param name="linkToEntityName"></param> /// <param name="linkFromAttributeName"></param> /// <param name="linkToAttributeName"></param> /// <param name="joinType"></param> /// <returns></returns> public static LinkEntity AddChildLink(this LinkEntity link, string linkToEntityName, string linkFromAttributeName, string linkToAttributeName, JoinOperator joinType) { var child = new LinkEntity( link.LinkToEntityName, linkToEntityName, linkFromAttributeName, linkToAttributeName, joinType); link.LinkEntities.Add(child); return(child); }
/// <summary> /// Adds the type T as a linked entity, additionally ensuring it is active. /// </summary> /// <typeparam name="T">The type of the entity that is to be linked and asserted active.</typeparam> /// <param name="qe">The query expression.</param> /// <param name="linkFromAttributeName">Name of the link from attribute.</param> /// <param name="linkToAttributeName">Name of the link to attribute.</param> /// <param name="joinType">Type of the join to perform.</param> /// <returns></returns> public static LinkEntity AddLink <T>(this QueryExpression qe, string linkFromAttributeName, string linkToAttributeName, JoinOperator joinType) where T : Entity { var link = qe.AddLink(EntityHelper.GetEntityLogicalName <T>(), linkFromAttributeName, linkToAttributeName, joinType); if (_activeOnly) { link.LinkCriteria.ActiveOnly <T>(); } return(link); }
public Link(string entityName, string toEntityName, string fromAttributeName, string toAttributeName, JoinOperator joinOperator, bool addColumns) : base(entityName) { ToEntityName = toEntityName; FromAttributeName = fromAttributeName; ToAttributeName = toAttributeName; JoinOperator = joinOperator; DoAddColumns = addColumns; Criteria = new QueryCriteria(LogicalOperator.And, ToEntityName); if (addColumns) { try { TargetDefinition = DefinitionCache.GetEntityDefinition(toEntityName); if (!string.IsNullOrEmpty(TargetDefinition.PrimaryIdAttributeName)) { AddColumn(TargetDefinition.PrimaryIdAttributeName); } if (!string.IsNullOrEmpty(TargetDefinition.PrimaryNameAttributeName)) { AddColumn(TargetDefinition.PrimaryNameAttributeName); } } catch (KeyNotFoundException) { // définition non trouvée } } }
/// <summary> /// Adds the new LinkEntity as a child to this LinkEntity, rather than this LinkEntity's LinkFrom Entity /// Assumes that the linkFromAttributeName and the linkToAttributeName are the same /// </summary> /// <param name="link"></param> /// <param name="linkToEntityName"></param> /// <param name="linkAttributesName"></param> /// <param name="joinType"></param> /// <returns></returns> public static LinkEntity AddChildLink(this LinkEntity link, string linkToEntityName, string linkAttributesName, JoinOperator joinType) { return(link.AddChildLink(linkToEntityName, linkAttributesName, linkAttributesName, joinType)); }
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 LinkEntity AddLink(string linkToEntityName, string linkFromAttributeName, string linkToAttributeName, JoinOperator joinOperator) { LinkEntity linkEntity = new LinkEntity() { LinkToEntityName = linkToEntityName, LinkFromAttributeName = linkFromAttributeName, LinkToAttributeName = linkToAttributeName, JoinOperator = joinOperator }; this.LinkEntities.Add(linkEntity); return linkEntity; }
/// <summary> /// Add New linked entity /// </summary> /// <param name="linkFromEntityName">From Entity Name</param> /// <param name="linkFromAttributeName">From Entity attribute Name</param> /// <param name="linkToEntityName">To Entity Name</param> /// <param name="linkToAttributeName">To Entity Attribute name</param> /// <param name="aliasName">Alias Name</param> /// <param name="joinOperator">Join Operator</param> public void AddNewLinkEntity(string linkFromEntityName, string linkFromAttributeName, string linkToEntityName, string linkToAttributeName, string aliasName, JoinOperator joinOperator) { this.currentLinkEntity = new LinkEntity() { LinkFromEntityName = linkFromEntityName, LinkFromAttributeName = linkFromAttributeName, LinkToEntityName = linkToEntityName, LinkToAttributeName = linkToAttributeName, EntityAlias = aliasName, JoinOperator = joinOperator }; }