本文整理汇总了C#中SelectStatement.Render方法的典型用法代码示例。如果您正苦于以下问题:C# SelectStatement.Render方法的具体用法?C# SelectStatement.Render怎么用?C# SelectStatement.Render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SelectStatement
的用法示例。
在下文中一共展示了SelectStatement.Render方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderSelect
/// <summary>Creates a <see cref="SelectStatement"/> that retrieves data that is to be updated. <b>null</b> if data dont't have to be fetched, ie. if bulk update is supported when using multiple tables.</summary>
public void RenderSelect(UpdateStatement update, DbmsType dbms, StringBuilder output, DbParameterCollection parameters)
{
// Al used objects must be cloned so that internal state of original objects is not changed.
// Clone target table.
IDbTable updateTableClone = update.Table.Clone(update.Table.Alias, update.Table.ColumnAliasesArePrefixed);
SelectStatement select = new SelectStatement(updateTableClone);
// Clone relations.
select.Relations = update.Relations.Clone();
// SearchCondition is not cloned.
select.Where = update.Where;
// Create select list that contains clones of all PKs of target rows and values of source columns used in set expressions.
select.SelectList.Add(updateTableClone.PrimaryKey);
DbRelation[] relations = select.Relations.Relations;
foreach (UpdateExpression setExpression in update.UpdateList)
{
// Add source columns.
foreach (IDbColumn originalSourceColumn in setExpression.SourceColumns)
{
// Skip columns already in list.
if (!select.SelectList.ContainsItemWithAlias(originalSourceColumn.Alias))
{
// Find cloned table that contains current source column.
// Cloned tables may be on either side, ie. parent od child, in one or more of the cloned relations. Find first occurence.
IDbTable sourceTable;
DbRelation relWithSourceTbl = Array.Find<DbRelation>(relations, (r) => r.Parent.HasEqualAliasAndNameAs(originalSourceColumn.Table));
if (relWithSourceTbl != null)
{
sourceTable = relWithSourceTbl.Parent;
}
else
{
relWithSourceTbl = Array.Find<DbRelation>(relations, (r) => r.Child.HasEqualAliasAndNameAs(originalSourceColumn.Table));
sourceTable = relWithSourceTbl.Child;
}
IDbColumn sourceColClone = sourceTable.Columns.GetByColumnName(originalSourceColumn.ColumnName);
select.SelectList.Add(sourceColClone);
}
}
}
select.Render(dbms, output, parameters);
}