当前位置: 首页>>代码示例>>C#>>正文


C# SelectStatement.Render方法代码示例

本文整理汇总了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);
        }
开发者ID:lordfist,项目名称:FistCore.Lib,代码行数:45,代码来源:GenericUpdater.cs


注:本文中的SelectStatement.Render方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。