Ejemplo n.º 1
0
        protected static string GetJoinStatement(StandardProviderParameters std, esDynamicQuerySerializable query)
        {
            string sql = String.Empty;

            IDynamicQuerySerializableInternal iQuery = query as IDynamicQuerySerializableInternal;

            if (iQuery.InternalJoinItems != null)
            {
                foreach (esJoinItem joinItem in iQuery.InternalJoinItems)
                {
                    esJoinItem.esJoinItemData joinData = (esJoinItem.esJoinItemData)joinItem;

                    switch (joinData.JoinType)
                    {
                    case esJoinType.InnerJoin:
                        sql += " INNER JOIN ";
                        break;

                    case esJoinType.LeftJoin:
                        sql += " LEFT JOIN ";
                        break;

                    case esJoinType.RightJoin:
                        sql += " RIGHT JOIN ";
                        break;

                    case esJoinType.FullJoin:
                        sql += " FULL JOIN ";
                        break;
                    }

                    IDynamicQuerySerializableInternal iSubQuery = joinData.Query as IDynamicQuerySerializableInternal;

                    sql += Shared.CreateFullName(std.request, joinData.Query);

                    sql += " " + iSubQuery.JoinAlias;

                    if (query.es.WithNoLock == true)
                    {
                        sql += " WITH (NOLOCK)";
                    }

                    sql += " ON ";

                    sql += GetComparisonStatement(std, query, joinData.WhereItems, String.Empty);
                }
            }
            return(sql);
        }
Ejemplo n.º 2
0
        protected static string GetJoinStatement(StandardProviderParameters std, esDynamicQuery query)
        {
            string sql = String.Empty;

            IDynamicQueryInternal iQuery = query as IDynamicQueryInternal;

            if (iQuery.InternalJoinItems != null)
            {
                foreach (esJoinItem joinItem in iQuery.InternalJoinItems)
                {
                    esJoinItem.esJoinItemData joinData = (esJoinItem.esJoinItemData)joinItem;

                    switch (joinData.JoinType)
                    {
                    case esJoinType.InnerJoin:
                        sql += " INNER JOIN ";
                        break;

                    case esJoinType.LeftJoin:
                        sql += " LEFT JOIN ";
                        break;

                    case esJoinType.RightJoin:
                        sql += " RIGHT JOIN ";
                        break;

                    case esJoinType.FullJoin:
                        sql += " FULL JOIN ";
                        break;
                    }

                    IDynamicQueryInternal iSubQuery = joinData.Query as IDynamicQueryInternal;

                    sql += Shared.CreateFullName((esProviderSpecificMetadata)iSubQuery.ProviderMetadata);

                    sql += " " + iSubQuery.JoinAlias + " ON ";

                    sql += GetComparisonStatement(std, query, joinData.WhereItems, String.Empty);
                }
            }
            return(sql);
        }
        protected static string GetJoinStatement(esDataRequest request, esDynamicQuerySerializable query, VistaDBCommand cmd, ref int pindex)
        {
            string sql = String.Empty;

            IDynamicQuerySerializableInternal iQuery = query as IDynamicQuerySerializableInternal;

            if (iQuery.InternalJoinItems != null)
            {
                foreach (esJoinItem joinItem in iQuery.InternalJoinItems)
                {
                    esJoinItem.esJoinItemData joinData = (esJoinItem.esJoinItemData)joinItem;

                    switch (joinData.JoinType)
                    {
                    case esJoinType.InnerJoin:
                        sql += " INNER JOIN ";
                        break;

                    case esJoinType.LeftJoin:
                        sql += " LEFT JOIN ";
                        break;

                    case esJoinType.RightJoin:
                        sql += " RIGHT JOIN ";
                        break;

                    case esJoinType.FullJoin:
                        sql += " FULL JOIN ";
                        break;
                    }

                    IDynamicQuerySerializableInternal iSubQuery = joinData.Query as IDynamicQuerySerializableInternal;

                    sql += Shared.CreateFullName((esProviderSpecificMetadata)iSubQuery.ProviderMetadata);

                    sql += " " + iSubQuery.JoinAlias + " ON ";

                    sql += GetComparisonStatement(request, query, joinData.WhereItems, String.Empty, cmd, ref pindex);
                }
            }
            return(sql);
        }
Ejemplo n.º 4
0
        protected static string GetJoinStatement(StandardProviderParameters std, esDynamicQuerySerializable query)
        {
            string sql = String.Empty;

            IDynamicQuerySerializableInternal iQuery = query as IDynamicQuerySerializableInternal;

            if (iQuery.InternalJoinItems != null)
            {
                foreach (esJoinItem joinItem in iQuery.InternalJoinItems)
                {
                    esJoinItem.esJoinItemData joinData = (esJoinItem.esJoinItemData)joinItem;

                    switch (joinData.JoinType)
                    {
                    case esJoinType.InnerJoin:
                        sql += " INNER JOIN ";
                        break;

                    case esJoinType.LeftJoin:
                        sql += " LEFT JOIN ";
                        break;

                    case esJoinType.RightJoin:
                        sql += " RIGHT JOIN ";
                        break;

                    case esJoinType.FullJoin:
                        sql += " FULL JOIN ";
                        break;
                    }

                    IDynamicQuerySerializableInternal iSubQuery = joinData.Query as IDynamicQuerySerializableInternal;

                    sql += Shared.CreateFullName((esProviderSpecificMetadata)iSubQuery.ProviderMetadata);
                    sql += " " + iSubQuery.JoinAlias + " ON ";

                    foreach (esComparison comparisonItem in joinData.WhereItems)
                    {
                        esComparison.esComparisonData comparisonData = (esComparison.esComparisonData)comparisonItem;

                        if (comparisonData.IsParenthesis)
                        {
                            if (comparisonData.Parenthesis == esParenthesis.Open)
                            {
                                sql += "(";
                            }
                            else
                            {
                                sql += ")";
                            }

                            continue;
                        }

                        if (comparisonData.IsConjunction)
                        {
                            if (comparisonData.Conjunction == esConjunction.And)
                            {
                                sql += " AND ";
                            }
                            else
                            {
                                sql += " OR ";
                            }

                            continue;
                        }

                        sql += GetColumnName(comparisonData.Column);

                        switch (comparisonData.Operand)
                        {
                        case esComparisonOperand.Equal:
                            sql += " = ";
                            break;

                        case esComparisonOperand.NotEqual:
                            sql += " <> ";
                            break;

                        case esComparisonOperand.GreaterThan:
                            sql += " > ";
                            break;

                        case esComparisonOperand.LessThan:
                            sql += " < ";
                            break;

                        case esComparisonOperand.LessThanOrEqual:
                            sql += " <= ";
                            break;

                        case esComparisonOperand.GreaterThanOrEqual:
                            sql += " >= ";
                            break;

                        case esComparisonOperand.IsNull:
                            sql += " IS NULL ";
                            break;

                        case esComparisonOperand.IsNotNull:
                            sql += " IS NOT NULL ";
                            break;

                        case esComparisonOperand.In:
                            sql += " IN ";
                            break;

                        case esComparisonOperand.NotIn:
                            sql += " NOT IN ";
                            break;
                        }

                        if (comparisonData.ComparisonColumn.Name != null)
                        {
                            sql += GetColumnName(comparisonData.ComparisonColumn);
                        }
                        else
                        {
                            esDynamicQuerySerializable subQuery = comparisonData.Value as esDynamicQuerySerializable;

                            if (subQuery != null)
                            {
                                sql += GetSubquerySearchCondition(subQuery) + " (" + BuildQuery(std, subQuery) + ")";
                            }
                            else if (comparisonData.Value != null)
                            {
                                // Handle Literals
                                sql += comparisonData.Value.ToString();
                            }
                        }
                    }

                    sql += ")";
                }
            }

            return(sql);
        }