public override string BuildQuerySQL(SQLServerVisitor <TextContent> visitor, out IEnumerable <Parameter> parameters) { string selectClause = "*"; if (visitor.SelectFields != null && visitor.SelectFields.Length > 0) { selectClause = string.Join(",", visitor.SelectFields); } string whereClause = visitor.WhereClause; if (textContentQuery.Folder != null) { var paraName = visitor.AppendParameter(textContentQuery.Folder.FullName); whereClause = whereClause + " AND FolderName=" + paraName; } var categoryClauses = string.Join(" AND ", GetCategoryClause(textContentQuery.Repository, visitor.CategoryQueries, visitor.Parameters).ToArray()); if (!string.IsNullOrEmpty(categoryClauses)) { whereClause = whereClause + " AND " + categoryClauses; } parameters = visitor.Parameters; string sql = string.Format("SELECT {0} FROM [{1}] content WHERE {2} ", selectClause, textContentQuery.Schema.GetTableName(), whereClause); return(sql); }
public override string BuildQuerySQL(SQLServerVisitor <MediaContent> visitor, out IEnumerable <Parameter> parameters) { string selectClause = "*"; if (visitor.SelectFields != null && visitor.SelectFields.Length > 0) { selectClause = string.Join(",", visitor.SelectFields); } string whereClause = visitor.WhereClause; var paraName = visitor.AppendParameter(mediaContentQuery.MediaFolder.FullName); whereClause = whereClause + "AND FolderName=" + paraName; parameters = visitor.Parameters; string sql = string.Format("SELECT {0} FROM {1} WHERE {2} ", selectClause, mediaContentQuery.Repository.GetMediaContentTableName(), whereClause); return(sql); }
public override string BuildQuerySQL(SQLServerVisitor <Models.TextContent> visitor, out IEnumerable <Parameter> parameters) { var innerVisitor = new SQLServerVisitor <Models.TextContent>(visitor.Parameters); innerVisitor.Visite(childrenQuery.ParentQuery.Expression); var innerExecutor = (new TextContentTranslator()).Translate(childrenQuery.ParentQuery); var innerQuerySQL = innerExecutor.BuildQuerySQL(innerVisitor, out parameters); string selectClause = "*"; if (visitor.SelectFields != null && visitor.SelectFields.Length > 0) { selectClause = string.Join(",", visitor.SelectFields); } string whereClause = visitor.WhereClause; if (childrenQuery.EmbeddedFolder != null) { var paraName = visitor.AppendParameter(childrenQuery.EmbeddedFolder.FullName); whereClause = whereClause + " AND FolderName=" + paraName; } //var paraName = visitor.AppendParameter(parentQuery.ChildrenQuery.FullName); //whereClause = whereClause + "AND FolderName=" + paraName; string sql = string.Format(@" SELECT {0} FROM [{1}] children WHERE EXISTS( SELECT UUID FROM ({2})parent WHERE parent.UUID = children.ParentUUID ) AND {3}", selectClause , childrenQuery.ChildSchema.GetTableName() , innerQuerySQL , whereClause); return(sql); }
public override string BuildQuerySQL(SQLServerVisitor <TextContent> visitor, out IEnumerable <Parameter> parameters) { var innerVisitor = new SQLServerVisitor <Models.TextContent>(visitor.Parameters); innerVisitor.Visite(categoriesQuery.InnerQuery.Expression); var innerExecutor = (new TextContentTranslator()).Translate(categoriesQuery.InnerQuery); var innerQuerySQL = innerExecutor.BuildQuerySQL(innerVisitor, out parameters); string selectClause = "*"; if (visitor.SelectFields != null && visitor.SelectFields.Length > 0) { selectClause = string.Join(",", visitor.SelectFields); } string whereClause = visitor.WhereClause; var paraName = visitor.AppendParameter(categoriesQuery.CategoryFolder.FullName); whereClause = whereClause + " AND FolderName=" + paraName; string sql = string.Format(@" SELECT {0} FROM [{1}] category WHERE EXISTS( SELECT ContentCategory.CategoryUUID FROM [{2}] ContentCategory, ({3})content WHERE content.UUID = ContentCategory.UUID AND ContentCategory.CategoryUUID = category.UUID ) AND {4}", selectClause , categoriesQuery.CategoryFolder.GetSchema().GetTableName() , categoriesQuery.Repository.GetCategoryTableName() , innerQuerySQL , whereClause); return(sql); }