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


C# DataView.Equals方法代码示例

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


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

示例1: TestEquals_SameTableDiffViewProp

        public void TestEquals_SameTableDiffViewProp()
        {
            DataTable table = new DataTable("table");
            table.Columns.Add("col1", typeof(int));
            table.Columns.Add("col2", typeof(int));
            for (int i = 0; i < 5; ++i)
                table.Rows.Add(new object[] { i, 100 + i });

            DataView view1 = new DataView(table);
            DataView view2 = new DataView(table);

            object obj2 = view2;
            Assert.False(view1.Equals(obj2));

            Assert.True(view1.Equals(view1));
            Assert.True(view2.Equals(view1));

            view1.Sort = "col1 ASC";
            Assert.False(view1.Equals(view2));
            view2.Sort = "col1 ASC";
            Assert.True(view1.Equals(view2));

            view1.RowFilter = "col1 > 100";
            Assert.False(view1.Equals(view2));
            view1.RowFilter = "";
            Assert.True(view1.Equals(view2));

            view1.RowStateFilter = DataViewRowState.Added;
            Assert.False(view1.Equals(view2));
            view1.RowStateFilter = DataViewRowState.CurrentRows;
            Assert.True(view1.Equals(view2));

            view1.AllowDelete = !view2.AllowDelete;
            Assert.False(view1.Equals(view2));
            view1.AllowDelete = view2.AllowDelete;
            Assert.True(view1.Equals(view2));

            view1.AllowEdit = !view2.AllowEdit;
            Assert.False(view1.Equals(view2));
            view1.AllowEdit = view2.AllowEdit;
            Assert.True(view1.Equals(view2));

            view1.AllowNew = !view2.AllowNew;
            Assert.False(view1.Equals(view2));
            view1.AllowNew = view2.AllowNew;
            Assert.True(view1.Equals(view2));

            //ApplyDefaultSort doesnet affect the comparision
            view1.ApplyDefaultSort = !view2.ApplyDefaultSort;
            Assert.True(view1.Equals(view2));

            DataTable table2 = table.Copy();
            view1.Table = table2;
            Assert.False(view1.Equals(view2));

            view1.Table = table;
            //well.. sort is set to null when Table is assigned..
            view1.Sort = view2.Sort;
            Assert.True(view1.Equals(view2));
        }
开发者ID:dotnet,项目名称:corefx,代码行数:60,代码来源:DataViewTest2.cs

示例2: SortDescriptionTest

        public void SortDescriptionTest()
        {
            IBindingListView view = new DataView(_table);

            ListSortDescriptionCollection col = view.SortDescriptions;

            ((DataView)view).Sort = "";
            col = view.SortDescriptions;
            Assert.Equal(0, col.Count);

            ((DataView)view).Sort = null;
            col = view.SortDescriptions;
            Assert.Equal(0, col.Count);

            ((DataView)view).Sort = "col1 DESC, col2 ASC";
            col = view.SortDescriptions;
            Assert.Equal(2, col.Count);
            Assert.Equal("col1", col[0].PropertyDescriptor.Name);
            Assert.Equal(ListSortDirection.Descending, col[0].SortDirection);
            Assert.Equal("col2", col[1].PropertyDescriptor.Name);
            Assert.Equal(ListSortDirection.Ascending, col[1].SortDirection);

            //ApplySort Test
            IBindingListView view1 = new DataView(_table);

            Assert.False(view.Equals(view1));
            view1.ApplySort(col);
            Assert.Equal("[col1] DESC,[col2]", ((DataView)view1).Sort);
            for (int i = 0; i < view.Count; ++i)
                Assert.Equal(((DataView)view)[i].Row, ((DataView)view1)[i].Row);
        }
开发者ID:dotnet,项目名称:corefx,代码行数:31,代码来源:DataViewTest_IBindingListView.cs


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