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


C# System.AsEnumerable方法代码示例

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


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

示例1: ByValue_Enumerable_CanDisallowNull

 public void ByValue_Enumerable_CanDisallowNull()
 {
     var data = new[]
     {
         new EmailAddress { Value = FakeData.Email(), },
         new EmailAddress { Value = FakeData.Email(), },
         new EmailAddress { Value = FakeData.Email(), },
     };
     data.AsEnumerable().ByValue(data[0].Value, false).ShouldNotBeNull();
     var exception = Assert.Throws<InvalidOperationException>(() =>
         data.AsEnumerable().ByValue(FakeData.Email(), false));
     Assert.NotNull(exception);
     exception.Message.IndexOf("Sequence contains no matching element", StringComparison.CurrentCulture)
         .ShouldEqual(0);
 }
开发者ID:phobos04,项目名称:tripod,代码行数:15,代码来源:QueryEmailAddressesTests.cs

示例2: Merge

        private static void Merge(System.Data.DataTable DestTable, System.Data.DataTable SrcTable)
        {
            string pk = DestTable.PrimaryKey[0].ColumnName;

            System.Data.DataRow[] pkChangedRows = DestTable.AsEnumerable().Where(p => p.RowState == DataRowState.Modified
                && !p[pk, DataRowVersion.Original].Equals(p[pk, DataRowVersion.Current])).ToArray();

            try
            {
                //When PK has changed, move row to added state
                foreach (System.Data.DataRow dr in pkChangedRows)
                {
                    dr.AcceptChanges();
                    dr.SetAdded();
                }

                DestTable.Merge(SrcTable);

            }
            finally
            {
                //And when back to modifyed
                foreach (System.Data.DataRow dr in pkChangedRows)
                {
                    dr.AcceptChanges();
                    dr.SetModified();
                }
            }

        }
开发者ID:data-avail,项目名称:DataAvail.WinForms,代码行数:30,代码来源:DbContextDataAdapter.cs

示例3: ToList_GivenAMultiDimensionalArray_ReturnsAnArrayWithAllItemsInIt

        public void ToList_GivenAMultiDimensionalArray_ReturnsAnArrayWithAllItemsInIt()
        {
            var array = new[,] { { 1, 2 }, { 3, 4 } };

            var list = array.AsEnumerable();

            CollectionAssert.AreEquivalent(list, array);
        }
开发者ID:EdwardSalter,项目名称:NCubeSolver,代码行数:8,代码来源:ArrayExtensionsTests.cs

示例4: Main

        static void Main(string[] args)
        {
            var a = new[] { new Program() };

            // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201401/20140120/avg

            var w = a.AsEnumerable().Where(x => x.Visible);

        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:9,代码来源:Program.cs

示例5: ByName_Enumerable_CanAllowNull

 public void ByName_Enumerable_CanAllowNull()
 {
     var data = new[]
     {
         new User { Name = FakeData.String() },
         new User { Name = FakeData.String() },
         new User { Name = FakeData.String() },
     };
     data.AsEnumerable().ByName(FakeData.String()).ShouldBeNull();
 }
开发者ID:phobos04,项目名称:tripod,代码行数:10,代码来源:QueryUsersTests.cs

示例6: ByValue_Enumerable_CanAllowNull

 public void ByValue_Enumerable_CanAllowNull()
 {
     var data = new[]
     {
         new EmailAddress { Value = FakeData.Email(), },
         new EmailAddress { Value = FakeData.Email(), },
         new EmailAddress { Value = FakeData.Email(), },
     };
     data.AsEnumerable().ByValue(FakeData.Email()).ShouldBeNull();
 }
开发者ID:phobos04,项目名称:tripod,代码行数:10,代码来源:QueryEmailAddressesTests.cs

示例7: ByTicket_Enumerable_CanAllowNull

 public void ByTicket_Enumerable_CanAllowNull()
 {
     var data = new[]
     {
         new EmailVerification { Ticket = FakeData.String(), },
         new EmailVerification { Ticket = FakeData.String(), },
         new EmailVerification { Ticket = FakeData.String(), },
     };
     data.AsEnumerable().ByTicket(FakeData.String()).ShouldBeNull();
 }
开发者ID:phobos04,项目名称:tripod,代码行数:10,代码来源:QueryEmailVerificationsTests.cs

示例8: Get_All_Persons

        public void Get_All_Persons()
        {
            // Arrange
            var allPersons = new[]
            {
                new Library.Entity.Person {FirstName = "John", LastName = "McClung", MiddleName = "Paul", Notes = "Crazy as can be"},
                new Library.Entity.Person {FirstName = "Katie", LastName = "McClung", MiddleName = "Elane", Notes = "Just as crazy as John"}
            };
            var service = Mock.Of<IPersonService>(s => s.All(null, null, "LastName") == allPersons.AsEnumerable());
            var controller = new PersonController(service);

            // Act
            var result = controller.Get(null, null, "LastName") as OkNegotiatedContentResult<IEnumerable<Web.Models.Person>>;
            var personModels = allPersons.AsEnumerable().ToModel();

            // Assert
            Assert.NotNull(result);
            Assert.True(personModels.SequenceEqual(result.Content));
        }
开发者ID:johnpmcclung,项目名称:FamilyTreeApp,代码行数:19,代码来源:PersonControllerTest.cs

示例9: ToList_GivenAMultiDimensionalArray_ReturnsAnArrayWithAllItemsInTheCorrectOrder

        public void ToList_GivenAMultiDimensionalArray_ReturnsAnArrayWithAllItemsInTheCorrectOrder()
        {
            var array = new[,] { { 1, 2 }, { 3, 4 } };

            var list = array.AsEnumerable().ToList();

            Assert.AreEqual(list[0], array[0, 0]);
            Assert.AreEqual(list[1], array[1, 0]);
            Assert.AreEqual(list[2], array[0, 1]);
            Assert.AreEqual(list[3], array[1, 1]);
        }
开发者ID:EdwardSalter,项目名称:NCubeSolver,代码行数:11,代码来源:ArrayExtensionsTests.cs

示例10: ByUserId_Enumerable_CanDisallowNull

        public void ByUserId_Enumerable_CanDisallowNull()
        {
            var userId = FakeData.Id();
            var otherUserId1 = FakeData.Id(userId);
            var otherUserId2 = FakeData.Id(userId, otherUserId1);
            var data = new[]
            {
                new LocalMembership { User = new ProxiedUser(otherUserId1), },
                new LocalMembership { User = new ProxiedUser(userId), },
                new LocalMembership { User = new ProxiedUser(otherUserId2), },
            };
            data.AsEnumerable().ByUserId(data[1].User.Id, false).ShouldNotBeNull();

            var otherUserId3 = FakeData.Id(userId, otherUserId1, otherUserId2);
            var exception = Assert.Throws<InvalidOperationException>(() =>
                data.AsEnumerable().ByUserId(otherUserId3, false));
            Assert.NotNull(exception);
            exception.Message.IndexOf("Sequence contains no matching element", StringComparison.CurrentCulture)
                .ShouldEqual(0);
        }
开发者ID:phobos04,项目名称:tripod,代码行数:20,代码来源:QueryLocalMembershipsTests.cs

示例11: ConstructorShouldAddFileTypeFilters

        public void ConstructorShouldAddFileTypeFilters()
        {
            // arrange
            var expected = new[] { "*.*", "*.txt", "*.csv" };

            // act
            var interaction = new SelectFolderInteraction( "", expected );
            var actual = interaction.FileTypeFilter;

            // assert
            Assert.Equal( expected.AsEnumerable(), actual.AsEnumerable() );
        }
开发者ID:WaffleSquirrel,项目名称:More,代码行数:12,代码来源:SelectFolderInteractionTest.cs

示例12: Point

        public void When_the_sequence_contains_more_than_a_single_point_the_Min_point_equals_the_element_wise_minimum_of_the_sequence()
        {
            var points = new[] {
                new Point(1, 2, 3),
                new Point(2, 3, 4),
                new Point(4, 5, 6),
                new Point(-1, 3, 7),
                new Point(0, 0, -10)
            };

            var aabb = AxisAlignedBoundingBox.FromPoints(points.AsEnumerable());

            Assert.Equal(new Point(-1, 0, -10), aabb.Min);
        }
开发者ID:pritisutar,项目名称:kelly,代码行数:14,代码来源:When_constructing_an_AABB_from_a_sequence_of_points.cs

示例13: ByUserId_Enumerable_CanAllowNull

        public void ByUserId_Enumerable_CanAllowNull()
        {
            var userId = FakeData.Id();
            var otherUserId1 = FakeData.Id(userId);
            var otherUserId2 = FakeData.Id(userId, otherUserId1);
            var data = new[]
            {
                new LocalMembership { User = new ProxiedUser(otherUserId1), },
                new LocalMembership { User = new ProxiedUser(userId), },
                new LocalMembership { User = new ProxiedUser(otherUserId2), },
            };

            var otherUserId3 = FakeData.Id(userId, otherUserId1, otherUserId2);
            data.AsEnumerable().ByUserId(otherUserId3).ShouldBeNull();
        }
开发者ID:phobos04,项目名称:tripod,代码行数:15,代码来源:QueryLocalMembershipsTests.cs

示例14: TestTryEnumerable

        public void TestTryEnumerable()
        {
            var expected = new[] {2, 3, 4, 5, 6};
            var initital = new[] {1, 2, 3, 4, 5};
            var @try = Try.Attempt(() => initital.AsEnumerable()).ToTryEnumerable();
            var temp =
                (from num in @try
                select num + 1)
                .Out();
            var result = temp.Match(
                success: BasicFunctions.Identity,
                failure: ex => Enumerable.Empty<int>());

            Assert.IsTrue(TestUtils.AreEqual(result, expected));

        }
开发者ID:RacoWireless,项目名称:FunctionalProgramming,代码行数:16,代码来源:TryEnumerableTests.cs

示例15: ByUserId_Enumerable_FiltersByUserId

        public void ByUserId_Enumerable_FiltersByUserId()
        {
            var userId = FakeData.Id();
            var data = new[]
            {
                new RemoteMembership { UserId = FakeData.Id(canNotBe: userId), },
                new RemoteMembership { UserId = userId, },
                new RemoteMembership { UserId = userId, },
                new RemoteMembership { UserId = FakeData.Id(canNotBe: userId), },
                new RemoteMembership { UserId = FakeData.Id(canNotBe: userId), },
                new RemoteMembership { UserId = userId, },
            };

            var results = data.AsEnumerable().ByUserId(userId).ToArray();
            results.ShouldNotBeNull();
            results.Length.ShouldEqual(3);
        }
开发者ID:phobos04,项目名称:tripod,代码行数:17,代码来源:QueryRemoteMembershipsTests.cs


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