本文整理汇总了C#中Table.GetFullHierarchyTableJoin方法的典型用法代码示例。如果您正苦于以下问题:C# Table.GetFullHierarchyTableJoin方法的具体用法?C# Table.GetFullHierarchyTableJoin怎么用?C# Table.GetFullHierarchyTableJoin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Table
的用法示例。
在下文中一共展示了Table.GetFullHierarchyTableJoin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBody
public static string GetBody(Table table, ModelRoot model)
{
StringBuilder sb = new StringBuilder();
if (table.AllowModifiedAudit)
{
sb.AppendLine("IF (@" + model.Database.ModifiedDateColumnName + " IS NULL)");
sb.AppendLine("SET @" + model.Database.ModifiedDateColumnName + " = GetDate();");
sb.AppendLine();
}
sb.AppendLine("SET NOCOUNT OFF;");
List<Table> tableList = table.GetTableHierarchy();
foreach (Table t in tableList)
{
sb.AppendLine("UPDATE ");
sb.AppendLine("[" + t.DatabaseName + "] ");
sb.AppendLine("SET");
sb.AppendLine(BuildSetStatement(t, model));
sb.AppendLine("WHERE");
sb.AppendLine("\t" + BuildUpdateWhereStatement(t, model, ((table == t) && table.AllowTimestamp)));
sb.AppendLine();
}
sb.AppendLine("SELECT");
sb.Append(Globals.BuildSelectList(table, model, true));
sb.AppendLine("FROM ");
sb.AppendLine(table.GetFullHierarchyTableJoin());
sb.AppendLine("WHERE");
sb.AppendLine("\t" + BuildSelectWhereStatement(table));
return sb.ToString();
}
示例2: BuildStoredProcedure
private static string BuildStoredProcedure(Table table, ModelRoot model, List<Column> allColumns)
{
StringBuilder sb = new StringBuilder();
int index = 0;
sb.AppendLine();
sb.AppendLine("CREATE TABLE #tmpTable");
sb.AppendLine("(");
foreach (Column dc in table.PrimaryKeyColumns)
{
sb.Append("[" + dc.DatabaseName + "]");
sb.Append(" ");
sb.Append(dc.DataType);
if (StringHelper.Match(dc.DataType.ToString(), "binary", true) ||
StringHelper.Match(dc.DataType.ToString(), "char", true) ||
StringHelper.Match(dc.DataType.ToString(), "decimal", true) ||
StringHelper.Match(dc.DataType.ToString(), "nchar", true) ||
StringHelper.Match(dc.DataType.ToString(), "numeric", true) ||
StringHelper.Match(dc.DataType.ToString(), "nvarchar", true) ||
StringHelper.Match(dc.DataType.ToString(), "varbinary", true) ||
StringHelper.Match(dc.DataType.ToString(), "varchar", true))
{
sb.Append("(" + dc.GetLengthString() + ")");
}
if (index < table.PrimaryKeyColumns.Count - 1)
sb.Append(",");
sb.AppendLine();
index++;
}
//sb.Remove(sb.Length - 3, 3);
sb.AppendLine(")");
sb.AppendLine();
sb.AppendLine("DECLARE @total__ivqatedr int");
sb.AppendLine("DECLARE @orderByColumnIndex int");
sb.AppendLine("-- remove top x values from the temp table based upon the specific page requested");
sb.AppendLine("SET @total__ivqatedr = (@pageSize * @page)");
sb.AppendLine("IF (@total__ivqatedr <> 0)");
sb.AppendLine("BEGIN");
sb.AppendLine(" SET ROWCOUNT @total__ivqatedr");
sb.AppendLine("END");
sb.AppendLine("INSERT INTO #tmpTable");
sb.AppendLine("(");
sb.Append(Globals.BuildPrimaryKeySelectList(model, table, false));
sb.AppendLine(")");
//SELECT CLAUSE
sb.AppendLine("SELECT");
sb.Append(Globals.BuildPrimaryKeySelectList(model, table, true));
sb.AppendLine("FROM");
sb.AppendLine(table.GetFullHierarchyTableJoin());
sb.AppendLine("WHERE");
for (int ii = 0; ii < allColumns.Count; ii++)
{
Column column = allColumns[ii];
//If this is text then do a like, other wise equals
string comparer = "=";
if (ModelHelper.IsTextType(column.DataType))
comparer = "LIKE";
string tableName = Globals.GetTableDatabaseName(model, (Table)column.ParentTableRef.Object);
sb.Append(" (@orderByColumn = '" + column.DatabaseName + "' and (((@filter is null) or ([" + tableName + "].[" + column.DatabaseName + "] is null)) or (@filter is not null and [" + tableName + "].[" + column.DatabaseName + "] " + comparer + " @filter)))");
if (ii < allColumns.Count - 1)
{
sb.AppendLine();
sb.Append("or");
}
sb.AppendLine();
}
//ORDER BY CLAUSE
sb.AppendLine("ORDER BY");
for (int ii = 0; ii < allColumns.Count; ii++)
{
Column column = allColumns[ii];
string tableName = Globals.GetTableDatabaseName(model, (Table)column.ParentTableRef.Object);
sb.AppendLine(" CASE @ascending WHEN 0 THEN CASE @orderByColumn WHEN '" + column.DatabaseName + "' THEN [" + tableName + "].[" + column.DatabaseName + "] END END DESC, ");
sb.Append(" CASE @ascending WHEN 1 THEN CASE @orderByColumn WHEN '" + column.DatabaseName + "' THEN [" + tableName + "].[" + column.DatabaseName + "] END END");
if (ii < allColumns.Count - 1)
{
sb.Append(", ");
}
sb.AppendLine();
}
sb.AppendLine();
sb.AppendLine("-- set @count based on the rows moved in the previous statement");
//sb.AppendLine("SET @count = ( SELECT count(*) FROM [#tmpTable] )" );
//REPEAT SELECT CLAUSE FOR COUNT
sb.AppendLine("SET ROWCOUNT 0");
sb.AppendLine("SET @count = (");
sb.AppendLine("SELECT count(*)");
sb.AppendLine("FROM");
sb.AppendLine(table.GetFullHierarchyTableJoin());
//.........这里部分代码省略.........