private static string ExtractStringFromTags(HtmlNode node, string xpath, NodeSection nodeSection = NodeSection.InnerText) { HtmlNodeCollection nodes = node.SelectNodes(xpath); string returnStr = ""; if (nodes != null && nodes.Count > 0) { HtmlNode nodeEntry = nodes.FirstOrDefault(); if (nodeEntry != null) { switch (nodeSection) { case NodeSection.InnerText: returnStr = nodeEntry.InnerText; break; case NodeSection.InnerHtml: returnStr = nodeEntry.InnerHtml; break; case NodeSection.OuterHtml: returnStr = nodeEntry.OuterHtml; break; default: throw new ArgumentOutOfRangeException(nameof(nodeSection), nodeSection, "Desired nodeSection not found"); } } } return(returnStr); }
public override string Translate(SqlCompilerContext context, SqlUnary node, NodeSection section) { //substitute UNIQUE predicate with a more complex EXISTS predicate, //because UNIQUE is not supported if (node.NodeType == SqlNodeType.Unique) { if (node.Operand is SqlSubQuery origSubselect) { var origQuery = SqlDml.QueryRef(origSubselect.Query); var existsOp = SqlDml.Select(origQuery); existsOp.Columns.Add(1); existsOp.Where = true; foreach (SqlColumn col in origQuery.Columns) { existsOp.Where = existsOp.Where && SqlDml.IsNotNull(col); existsOp.GroupBy.Add(col); } existsOp.Having = SqlDml.Count(SqlDml.Asterisk) > 1; existsOp.Limit = 1; node.ReplaceWith(SqlDml.Not(SqlDml.Exists(existsOp))); } } return(base.Translate(context, node, section)); }
public override string Translate(SqlCompilerContext context, SqlOrder node, NodeSection section) { if (section == NodeSection.Exit) { return(node.Ascending ? "ASC NULLS FIRST" : "DESC NULLS LAST"); } return(string.Empty); }
/// <inheritdoc/> public override string Translate(SqlCompilerContext context, SqlCast node, NodeSection section) { //http://www.sqlite.org/lang_expr.html var sqlType = node.Type.Type; if (sqlType == SqlType.DateTime || sqlType == SqlType.DateTimeOffset) { switch (section) { case NodeSection.Entry: return(string.Format("STRFTIME('{0}', ", DateTimeCastFormat)); case NodeSection.Exit: return(")"); default: throw new ArgumentOutOfRangeException("section"); } } if (sqlType == SqlType.Binary || sqlType == SqlType.Char || sqlType == SqlType.Interval || sqlType == SqlType.Int16 || sqlType == SqlType.Int32 || sqlType == SqlType.Int64) { switch (section) { case NodeSection.Entry: return("CAST("); case NodeSection.Exit: return("AS " + Translate(node.Type) + ")"); default: throw new ArgumentOutOfRangeException("section"); } } if (sqlType == SqlType.Decimal || sqlType == SqlType.Double || sqlType == SqlType.Float) { switch (section) { case NodeSection.Entry: return(string.Empty); case NodeSection.Exit: return("+ 0.0"); default: throw new ArgumentOutOfRangeException("section"); } } return(string.Empty); }
public override string Translate(SqlCompilerContext context, SqlOrder node, NodeSection section) { switch (section) { case NodeSection.Exit: return((node.Ascending) ? "ASC NULLS FIRST" : "DESC NULLS LAST"); } return(string.Empty); }
public override string Translate(SqlCompilerContext context, SqlCast node, NodeSection section) { // casting this way behaves differently: -32768::int2 is out of range ! We need (-32768)::int2 switch (section) { case NodeSection.Entry: return("("); case NodeSection.Exit: return(")::" + Translate(node.Type)); } return(string.Empty); }
//TODO: Concat Fix and not introduce problems with numerics. a+b. Translate 'a' + 'b' => concat('a', 'b') //public override string Translate(SqlCompilerContext context, SqlBinary node, NodeSection section) //{ // switch (section) // { // case NodeSection.Entry: // return (node.NodeType == SqlNodeType.RawConcat) ? string.Empty : "CONCAT("; // case NodeSection.Exit: // return (node.NodeType == SqlNodeType.RawConcat) ? string.Empty : ClosingParenthesis; // } // return string.Empty; //} public override string Translate(SqlCompilerContext context, SqlConcat node, NodeSection section) { switch (section) { case NodeSection.Entry: return("CONCAT("); case NodeSection.Exit: return(")"); default: return(string.Empty); } }
/// <inheritdoc/> public override string Translate(SqlCompilerContext context, SqlCast node, NodeSection section) { if (node.Type.Type == SqlType.DateTime) { switch (section) { case NodeSection.Entry: return("CAST("); case NodeSection.Exit: return("AS " + Translate(node.Type) + "(6))"); default: throw new ArgumentOutOfRangeException("section"); } } return(base.Translate(context, node, section)); }
public override string Translate(SqlCompilerContext context, SqlCast node, NodeSection section) { var sqlType = node.Type.Type; if (sqlType == SqlType.Char || sqlType == SqlType.VarChar || sqlType == SqlType.VarCharMax) { switch (section) { case NodeSection.Entry: return("TO_CHAR("); case NodeSection.Exit: return(")"); default: throw new ArgumentOutOfRangeException("section"); } } return(base.Translate(context, node, section)); }
public override string Translate(SqlCompilerContext context, SqlNextValue node, NodeSection section) { switch (section) { case NodeSection.Entry: return("nextval('"); case NodeSection.Exit: return("')"); } return(string.Empty); }
public override string Translate(SqlCompilerContext context, SqlCreateView node, NodeSection section) { switch (section) { case NodeSection.Entry: var sb = new StringBuilder(); if (node.View.ViewColumns.Count > 0) { sb.Append(" ("); bool first = true; foreach (DataTableColumn c in node.View.ViewColumns) { if (first) { first = false; } else { sb.Append(ColumnDelimiter); } sb.Append(c.DbName); } sb.Append(")"); } return(sb.ToString()); case NodeSection.Exit: return(string.Empty); default: return(string.Empty); } }
public override string Translate(SqlCompilerContext context, SqlCreateView node, NodeSection section) { switch (section) { case NodeSection.Exit: if (node.View.CheckOptions == CheckOptions.Cascaded) { return("WITH CHECK OPTION"); } else { return(string.Empty); } default: return(base.Translate(context, node, section)); } }
/// <inheritdoc/> public override string Translate(SqlCompilerContext context, SqlCast node, NodeSection section) { var sqlType = node.Type.Type; if (sqlType == SqlType.Binary || sqlType == SqlType.Char || sqlType == SqlType.Interval || sqlType == SqlType.DateTime) { switch (section) { case NodeSection.Entry: return("CAST("); case NodeSection.Exit: return("AS " + Translate(node.Type) + ")"); default: throw new ArgumentOutOfRangeException("section"); } } if (sqlType == SqlType.Int16 || sqlType == SqlType.Int32) { switch (section) { case NodeSection.Entry: return("CAST("); case NodeSection.Exit: return("AS SIGNED " + Translate(node.Type) + ")"); default: throw new ArgumentOutOfRangeException("section"); } } if (sqlType == SqlType.Decimal) { switch (section) { case NodeSection.Entry: return("CAST("); case NodeSection.Exit: return("AS " + Translate(node.Type) + ")"); default: throw new ArgumentOutOfRangeException("section"); } } if (sqlType == SqlType.Decimal || sqlType == SqlType.Double || sqlType == SqlType.Float) { switch (section) { case NodeSection.Entry: return(String.Empty); case NodeSection.Exit: return(String.Empty); default: throw new ArgumentOutOfRangeException("section"); } } return(string.Empty); }
/// <inheritdoc/> public override string Translate(SqlCompilerContext context, SqlNextValue node, NodeSection section) { throw new NotSupportedException(Strings.ExDoesNotSupportSequences); }
public override string Translate(SqlCompilerContext context, SqlCreateSequence node, NodeSection section) { if (section == NodeSection.Entry) { return(TranslateSequenceStatement(context, node.Sequence, "CREATE")); } return(string.Empty); }
/// <inheritdoc/> public override string Translate(SqlCompilerContext context, SqlNextValue node, NodeSection section) { switch (section) { case NodeSection.Entry: return("GEN_ID("); case NodeSection.Exit: return("," + node.Increment + ")"); } return(string.Empty); }
public override string Translate(SqlCompilerContext context, SqlAssignment node, NodeSection section) { return(string.Empty); }
public override string Translate(SqlCompilerContext context, SqlNextValue node, NodeSection section) { switch (section) { case NodeSection.Exit: return(".nextval"); default: return(string.Empty); } }
/// <inheritdoc/> public override string Translate(SqlCompilerContext context, SqlAlterSequence node, NodeSection section) { switch (section) { case NodeSection.Entry: return("SET GENERATOR " + Translate(context, node.Sequence)); case NodeSection.Exit: return("TO " + (node.SequenceDescriptor.LastValue.HasValue ? node.SequenceDescriptor.LastValue : 0)); } return(string.Empty); }
public override string Translate(SqlCompilerContext context, SqlNextValue node, NodeSection section) { if (section == NodeSection.Entry) { return("nextval('"); } if (section == NodeSection.Exit) { return("')"); } return(string.Empty); }