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


C# Filter.AddOrderByColumn方法代码示例

本文整理汇总了C#中Filter.AddOrderByColumn方法的典型用法代码示例。如果您正苦于以下问题:C# Filter.AddOrderByColumn方法的具体用法?C# Filter.AddOrderByColumn怎么用?C# Filter.AddOrderByColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Filter的用法示例。


在下文中一共展示了Filter.AddOrderByColumn方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateScriptObjects


//.........这里部分代码省略.........
                if (oldScriptObject == null || oldScriptObject.IsUserDefined)
                {
                    continue;
                }
                // Find old user defined filters
                Filter[] userDefinedFilters = GetUserDefinedFilters(oldScriptObject.Filters);

                foreach (Filter oldFilter in userDefinedFilters)
                {
                    Interfaces.Events.RaiseObjectBeingProcessedEvent(oldFilter.Name, "Filter");

                    Filter newFilter = new Filter(oldFilter.Name, oldFilter.IsUserDefined, newScriptObject, oldFilter.IsReturnTypeCollection, oldFilter.CreateStoredProcedure,
                        oldFilter.UseCustomWhere, oldFilter.CustomWhere, oldFilter.Key);

                    newFilter.Alias = oldFilter.Alias;
                    newFilter.Name = oldFilter.Name;
                    newFilter.CustomWhere = oldFilter.CustomWhere;
                    newFilter.CreateStoredProcedure = oldFilter.CreateStoredProcedure;
                    newFilter.Enabled = oldFilter.Enabled;
                    newFilter.IsReturnTypeCollection = oldFilter.IsReturnTypeCollection;

                    foreach (Filter.FilterColumn oldFilterColumn in oldFilter.FilterColumns)
                    {
                        Column newFilterColumnColumn = GetNewScriptBase(newDatabase.AllScriptObjects, oldFilter, oldFilterColumn.Column);

                        Filter.FilterColumn newFilterColumn = new Filter.FilterColumn(newFilterColumnColumn, oldFilterColumn.LogicalOperator, oldFilterColumn.CompareOperator, oldFilterColumn.Alias);
                        newFilter.AddFilterColumn(newFilterColumn);
                    }
                    foreach (Filter.OrderByColumn oldOrderByColumn in oldFilter.OrderByColumns)
                    {
                        Column newOrderByColumnColumn = GetNewScriptBase(newDatabase.AllScriptObjects, oldFilter, oldOrderByColumn.Column);

                        Filter.OrderByColumn newOrderByColumn = new Filter.OrderByColumn(newOrderByColumnColumn, oldOrderByColumn.SortOperator);
                        newFilter.AddOrderByColumn(newOrderByColumn);
                    }
                    newScriptObject.AddFilter(newFilter);
                }
            }

            #endregion

            #region Relationship

            Interfaces.Events.RaiseObjectBeingProcessedEvent("", "Updating Relationships");

            // Update new script objects with old properties
            foreach (ScriptObject newScriptObject in newDatabase.AllScriptObjects)
            {
                if ((newScriptObject.IsTable && !processTables) ||
                    (newScriptObject.IsStoredProcedure && !processStoredProcedures) ||
                    (newScriptObject.IsView && !processViews))
                {
                    continue;
                }
                // Find old script object if it exists
                ScriptObject oldScriptObject = Search.GetScriptObject(oldDatabase.AllScriptObjects, newScriptObject, newScriptObject.GetType(), false);

                if (oldScriptObject == null)// || oldScriptObject.IsUserDefined)
                {
                    continue;
                }
                // Find old user defined relationships
                Relationship[] userDefinedRelationships = GetUserDefinedRelationships(oldScriptObject.Relationships);

                foreach (Relationship oldRelationship in userDefinedRelationships)
                {
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:67,代码来源:Database.cs

示例2: InitialCreateFilters

        private static void InitialCreateFilters(IList<Model.Table> tables)
        {
            foreach (Model.Table table in tables)
            {
                // Get All Filter
                string allAlias = "Get" + table.AliasPlural;
                Filter allFilter = new Filter(allAlias, false, table, true, true, false, "", null);

                foreach (Column primaryKeyColumn in table.PrimaryKeyColumns)
                {
                    Filter.OrderByColumn orderByColumn = new Filter.OrderByColumn(primaryKeyColumn, "ASC");
                    allFilter.AddOrderByColumn(orderByColumn);
                }

                // Filter[0]
                table.AddFilter(allFilter);

                // Filter[1]
                foreach (Key key in table.Keys)
                {
                    if (key.Type == DatabaseConstant.KeyType.Primary)
                    {
                        //string filterAlias = Helper.GetFilterAlias(key);
                        bool isReturnTypeCollection = false;

                        Filter filter = new Filter(key.Name, false, key.Parent, isReturnTypeCollection, true, false, "", key);

                        foreach (Column column in key.Columns)
                        {
                            string logicalOperator = "";
                            if (filter.FilterColumns.Length > 0)
                            {
                                logicalOperator = "And";
                            }
                            Filter.FilterColumn filterColumn = new Filter.FilterColumn(column, logicalOperator, null, null);
                            filter.AddFilterColumn(filterColumn);
                        }

                        table.AddFilter(filter);
                    }
                }

                // Remaing filters
                foreach (Key key in table.Keys)
                {
                    if (key.Type == DatabaseConstant.KeyType.Foreign ||
                        key.Type == DatabaseConstant.KeyType.Unique ||
                        key.Type == DatabaseConstant.KeyType.None
                        )
                    {
                        //string filterAlias = Helper.GetFilterAlias(key);
                        bool isReturnTypeCollection = false;
                        if (key.Type == DatabaseConstant.KeyType.Foreign ||
                            key.Type == DatabaseConstant.KeyType.None
                            )
                        {
                            isReturnTypeCollection = true;
                        }
                        Filter filter = new Filter(key.Name, false, key.Parent, isReturnTypeCollection, true, false, "", key);

                        foreach (Column column in key.Columns)
                        {
                            string logicalOperator = "";
                            if (filter.FilterColumns.Length > 0)
                            {
                                logicalOperator = "And";
                            }

                            Filter.FilterColumn filterColumn = new Filter.FilterColumn(column, logicalOperator, null, null);
                            filter.AddFilterColumn(filterColumn);
                        }

                        if (isReturnTypeCollection)
                        {
                            foreach (Column primaryKeyColumn in table.PrimaryKeyColumns)
                            {
                                Filter.OrderByColumn orderByColumn = new Filter.OrderByColumn(primaryKeyColumn, "ASC");
                                filter.AddOrderByColumn(orderByColumn);
                            }
                        }

                        table.AddFilter(filter);
                    }
                }

                /*foreach (Index index in table.Indexes)
                {
                    if (index.Type == DatabaseConstant.IndexType.Unique ||
                        index.Type == DatabaseConstant.IndexType.None)
                    {
                        string filterAlias = Helper.GetFilterAlias(index);
                        bool isReturnTypeCollection = false;
                        if (index.Type == DatabaseConstant.KeyType.None)
                        {
                            isReturnTypeCollection = true;
                        }

                        Filter filter = new Filter(index.Name, filterAlias, false, index.Parent, isReturnTypeCollection, true, false, "");

                        foreach (Column column in index.Columns)
//.........这里部分代码省略.........
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:101,代码来源:Table.cs

示例3: SyncFilterProperties


//.........这里部分代码省略.........
            }
            #endregion

            #region OrderByColumns
            for (int orderColumnCounter = newFilter.OrderByColumns.Length - 1; orderColumnCounter >= 0; orderColumnCounter--)
            {
                Filter.OrderByColumn newColumn = newFilter.OrderByColumns[orderColumnCounter];
                bool found = false;

                foreach (Filter.OrderByColumn oldColumn in oldFilter.OrderByColumns)
                {
                    if (newColumn.Column.Name == oldColumn.Column.Name &&
                        newColumn.Column.Parent.Name == oldColumn.Column.Parent.Name)
                    {
                        newColumn.SortOperator = oldColumn.SortOperator;
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    newFilter.RemoveOrderByColumn(newColumn);
                }
            }
            #endregion

            #region Add missing FilterColumns
            foreach (Filter.FilterColumn oldColumn in oldFilter.FilterColumns)
            {
                bool found = false;

                foreach (Filter.FilterColumn newColumn in newFilter.FilterColumns)
                {
                    if (newColumn.Column.Name == oldColumn.Column.Name &&
                        newColumn.Column.Parent.Name == oldColumn.Column.Parent.Name)
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    bool success = false;

                    foreach (Column column in newFilter.Parent.Columns)
                    {
                        if (column.Name == oldColumn.Column.Name &&
                            column.Parent.Name == oldColumn.Column.Parent.Name)
                        {
                            Filter.FilterColumn filterColumn = new Filter.FilterColumn(column, oldColumn.LogicalOperator, oldColumn.CompareOperator, oldColumn.Alias);
                            newFilter.AddFilterColumn(filterColumn);
                            success = true;
                            break;
                        }
                    }
                    if (!success)
                    {
                        //sb.AppendLine(string.Format("Filter column is missing and couldn't be updated. Filter:{0}, Column:{1}.{2}", newFilter.Alias, oldColumn.Column.Parent.Name, oldColumn.Column.Alias));
                    }
                }
            }
            #endregion

            #region Add missing OrderByColumns
            foreach (Filter.OrderByColumn oldColumn in oldFilter.OrderByColumns)
            {
                bool found = false;

                foreach (Filter.OrderByColumn newColumn in newFilter.OrderByColumns)
                {
                    if (newColumn.Column.Name == oldColumn.Column.Name &&
                        newColumn.Column.Parent.Name == oldColumn.Column.Parent.Name)
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    bool success = false;

                    foreach (Column column in newFilter.Parent.Columns)
                    {
                        if (column.Name == oldColumn.Column.Name &&
                            column.Parent.Name == oldColumn.Column.Parent.Name)
                        {
                            Filter.OrderByColumn orderByColumn = new Filter.OrderByColumn(column, oldColumn.SortOperator);
                            newFilter.AddOrderByColumn(orderByColumn);
                            success = true;
                            break;
                        }
                    }
                    if (!success)
                    {
                        sb.AppendLine(string.Format("OrderBy column is missing and couldn't be updated. Filter:{0}, Column:{1}", newFilter.Alias, oldColumn.Column.Parent.Name + oldColumn.Column.Alias));
                    }
                }
            }
            #endregion
            }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:101,代码来源:Database.cs


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