本文整理汇总了C#中ISqlDialect.UseIndex方法的典型用法代码示例。如果您正苦于以下问题:C# ISqlDialect.UseIndex方法的具体用法?C# ISqlDialect.UseIndex怎么用?C# ISqlDialect.UseIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISqlDialect
的用法示例。
在下文中一共展示了ISqlDialect.UseIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToString
public string ToString(ISqlDialect dialect)
{
var sql = new StringBuilder();
sql.Append("select ");
if (distinct) sql.Append("distinct ");
if (selectAll)
{
sql.Append("*");
}
else
{
columns.ForEach(column => sql.AppendFormat("{0}, ", column.ToString(dialect)));
sql.Remove(sql.Length - 2, 2);
}
if (0 < tables.Count)
{
sql.Append(" from ");
tables.ForEach(table => sql.AppendFormat("{0}, ", table.ToString(dialect)));
sql.Remove(sql.Length - 2, 2);
}
if (!string.IsNullOrEmpty(index))
{
sql.AppendFormat(" {0}", dialect.UseIndex(index));
}
if (0 < joins.Count)
{
foreach (JoinInfo join in joins)
{
if (join.JoinType == SqlJoin.Inner) sql.Append(" inner join ");
if (join.JoinType == SqlJoin.LeftOuter) sql.Append(" left outer join ");
if (join.JoinType == SqlJoin.RightOuter) sql.Append(" right outer join ");
sql.AppendFormat("{0} on {1}", join.With.ToString(dialect), join.On.ToString(dialect));
}
}
if (where != Exp.Empty) sql.AppendFormat(" where {0}", where.ToString(dialect));
if (0 < groups.Count)
{
sql.Append(" group by ");
foreach (object group in groups)
{
sql.AppendFormat("{0}, ", group.ToString());
}
sql.Remove(sql.Length - 2, 2);
}
if (having != Exp.Empty) sql.AppendFormat(" having {0}", having.ToString(dialect));
if (0 < orders.Count)
{
sql.Append(" order by ");
foreach (var order in orders)
{
sql.Append(order.Key.ToString());
sql.AppendFormat(" {0}, ", order.Value ? "asc" : "desc");
}
sql.Remove(sql.Length - 2, 2);
}
if (0 < maxResults)
{
sql.AppendFormat(" limit {0}", maxResults);
if (0 < firstResult) sql.AppendFormat(" offset {0}", firstResult);
}
if (forupdate)
{
sql.Append(" for update");
}
unions.ForEach(u => sql.AppendFormat(" union {0}{1}", u.UnionAll ? "all " : string.Empty, u.Query.ToString(dialect)));
return sql.ToString();
}