public string Compile(Query query, int top, int skip, SortField[] orders, out SenseNet.ContentRepository.Storage.Search.NodeQueryParameter[] parameters) { throw new NotImplementedException("Partially implemented."); if (skip > 0) { throw new NotImplementedException("Paging is not implemented (skip > 0)."); } var whereCompiler = new SqlWhereVisitor(); whereCompiler.Visit(query); var sb = new StringBuilder(); sb.Append("SELECT"); if (top > 0) { sb.Append(" TOP ").Append(top); } sb.AppendLine(" NodeId FROM Nodes"); sb.Append("WHERE "); sb.AppendLine(whereCompiler.ToString()); if (orders.Count() > 0) { sb.Append("ORDER BY "); sb.AppendLine(String.Join(", ", orders.Select(o => o.GetField() + (o.GetReverse() ? " DESC" : String.Empty)).ToArray())); } parameters = whereCompiler.Parameters; return(sb.ToString()); }
public string Compile(Query query, int top, int skip, SortField[] orders, bool countOnly, out SenseNet.ContentRepository.Storage.Search.NodeQueryParameter[] parameters) { if (countOnly) { throw new SnNotSupportedException("'CountOnly' is not supported."); } if (skip > 0) { throw new SnNotSupportedException("Paging is not supported (skip > 0)."); } var whereCompiler = new SqlWhereVisitor(); whereCompiler.Visit(query); var sb = new StringBuilder(); sb.Append("SELECT"); if (top > 0 && top < int.MaxValue) { sb.Append(" TOP ").Append(top); } sb.AppendLine(" NodeId, LastMajorVersionId FROM Nodes"); sb.Append("WHERE "); sb.AppendLine(whereCompiler.ToString()); if (orders != null && orders.Count() > 0) { sb.Append("ORDER BY "); sb.AppendLine(String.Join(", ", orders.Select(o => _sqlFields[o.GetField()].SqlName + (o.GetReverse() ? " DESC" : String.Empty)).ToArray())); } parameters = whereCompiler.Parameters; return(sb.ToString()); }
public string Compile(Query query, int top, int skip, SortField[] orders, out SenseNet.ContentRepository.Storage.Search.NodeQueryParameter[] parameters) { throw new NotImplementedException("Partially implemented."); if(skip > 0) throw new NotImplementedException("Paging is not implemented (skip > 0)."); var whereCompiler = new SqlWhereVisitor(); whereCompiler.Visit(query); var sb = new StringBuilder(); sb.Append("SELECT"); if(top > 0) sb.Append(" TOP ").Append(top); sb.AppendLine(" NodeId FROM Nodes"); sb.Append("WHERE "); sb.AppendLine(whereCompiler.ToString()); if (orders.Count() > 0) { sb.Append("ORDER BY "); sb.AppendLine(String.Join(", ", orders.Select(o => o.GetField() + (o.GetReverse() ? " DESC" : String.Empty)).ToArray())); } parameters = whereCompiler.Parameters; return sb.ToString(); }