protected static string GetFromStatement(StandardProviderParameters std, tgDynamicQuerySerializable query) { IDynamicQuerySerializableInternal iQuery = query as IDynamicQuerySerializableInternal; string sql = String.Empty; if (iQuery.InternalFromQuery == null) { sql = Shared.CreateFullName(query); if (iQuery.JoinAlias != " ") { sql += " " + iQuery.JoinAlias; } } else { IDynamicQuerySerializableInternal iSubQuery = iQuery.InternalFromQuery as IDynamicQuerySerializableInternal; iSubQuery.IsInSubQuery = true; sql += "("; sql += BuildQuery(std, iQuery.InternalFromQuery); sql += ")"; if (iSubQuery.SubQueryAlias != " ") { sql += " AS " + iSubQuery.SubQueryAlias; } iSubQuery.IsInSubQuery = false; } return(sql); }
protected static string GetJoinStatement(StandardProviderParameters std, tgDynamicQuerySerializable query) { string sql = String.Empty; IDynamicQuerySerializableInternal iQuery = query as IDynamicQuerySerializableInternal; if (iQuery.InternalJoinItems != null) { foreach (tgJoinItem joinItem in iQuery.InternalJoinItems) { tgJoinItem.tgJoinItemData joinData = (tgJoinItem.tgJoinItemData)joinItem; switch (joinData.JoinType) { case tgJoinType.InnerJoin: sql += " INNER JOIN "; break; case tgJoinType.LeftJoin: sql += " LEFT JOIN "; break; case tgJoinType.RightJoin: sql += " RIGHT JOIN "; break; case tgJoinType.FullJoin: sql += " FULL JOIN "; break; } IDynamicQuerySerializableInternal iSubQuery = joinData.Query as IDynamicQuerySerializableInternal; sql += Shared.CreateFullName((tgProviderSpecificMetadata)iSubQuery.ProviderMetadata); sql += " " + iSubQuery.JoinAlias + " ON "; sql += GetComparisonStatement(std, query, joinData.WhereItems, String.Empty); } } return(sql); }