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


C# MemberMapper.Project方法代码示例

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


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

示例1: NestedPropertyWithCustomMappingWorks

        public void NestedPropertyWithCustomMappingWorks()
        {
            var mapper = new MemberMapper();

              mapper.CreateMap<Address, AddressDto>(src => new AddressDto
              {
            CountryName = src.Country.Name
              });

              var projection = mapper.Project<CustomerSingleAddress, CustomerSingleAddressDto>();

              var method = projection.Compile();

              var result = method(new CustomerSingleAddress
              {
            Address =
              new Address
              {
            Country = new Country
            {
              Name = "X"
            }
              }
              });

              Assert.AreEqual("X", result.Address.CountryName);
        }
开发者ID:JulianR,项目名称:ThisMember,代码行数:27,代码来源:ProjectionCustomMappingsTests.cs

示例2: AsProjectableFirstThrowsWhenLessThanOne

        public void AsProjectableFirstThrowsWhenLessThanOne()
        {
            var mapper = new MemberMapper();

              var source = new List<SourceType>
              {
              };

              var result = source.AsQueryable().AsProjectable().First(mapper.Project<SourceType, DestinationType>());
        }
开发者ID:JulianR,项目名称:ThisMember,代码行数:10,代码来源:ProjectableTests.cs

示例3: AsProjectableFirstOrDefaultReturnsDefaultWhenLessThanOne

        public void AsProjectableFirstOrDefaultReturnsDefaultWhenLessThanOne()
        {
            var mapper = new MemberMapper();

              var source = new List<SourceType>
              {
              };

              var result = source.AsQueryable().AsProjectable().FirstOrDefault(mapper.Project<SourceType, DestinationType>());

              Assert.IsNull(result);
        }
开发者ID:JulianR,项目名称:ThisMember,代码行数:12,代码来源:ProjectableTests.cs

示例4: CustomMappingsWorkWithProjections

        public void CustomMappingsWorkWithProjections()
        {
            var mapper = new MemberMapper();

              mapper.CreateMap<SourceType, DestinationType>(src => new DestinationType
              {
            FullName = src.FirstName + " " + src.LastName
              });

              var projection = mapper.Project<SourceType, DestinationType>().Compile();

              var result = projection(new SourceType { FirstName = "First", LastName = "Last" });

              Assert.AreEqual("First Last", result.FullName);
        }
开发者ID:JulianR,项目名称:ThisMember,代码行数:15,代码来源:ProjectionCustomMappingsTests.cs

示例5: NestedProjectionWorks

        public void NestedProjectionWorks()
        {
            var mapper = new MemberMapper();

              var result = mapper.Project<ComplexSourceType, ComplexDestinationType>().Compile()(
            new ComplexSourceType
            {
              ID = 1,
              Foo = new NestedSourceType
              {
            Name = "Foo"
              }
            });

              Assert.AreEqual(1, result.ID);
              Assert.AreEqual("Foo", result.Foo.Name);
        }
开发者ID:JulianR,项目名称:ThisMember,代码行数:17,代码来源:ProjectionTests.cs

示例6: ProjectionOfArrayToICollectionWorks

        public void ProjectionOfArrayToICollectionWorks()
        {
            var mapper = new MemberMapper();

              var projection = mapper.Project<ArrayType, OtherICollectionType>().Compile();

              var result = projection(new ArrayType
              {
            Foos = new NestedEnumerableSourceType[]
              {
            new NestedEnumerableSourceType
            {
              Name = "Test"
            }
              }
              });

              Assert.AreEqual("Test", result.Foos.Single().Name);
        }
开发者ID:JulianR,项目名称:ThisMember,代码行数:19,代码来源:ProjectionTests.cs

示例7: AsProjectableFirstWorks

        public void AsProjectableFirstWorks()
        {
            var mapper = new MemberMapper();

              var source = new List<SourceType>
              {
            new SourceType
            {
              ID = 10
            },
             new SourceType
            {
              ID = 20
            }
              };

              var result = source.AsQueryable().AsProjectable().First(mapper.Project<SourceType, DestinationType>());

              Assert.AreEqual(10, result.ID);
        }
开发者ID:JulianR,项目名称:ThisMember,代码行数:20,代码来源:ProjectableTests.cs

示例8: NoCollectionMappingOptionIsRespected

        public void NoCollectionMappingOptionIsRespected()
        {
            var mapper = new MemberMapper();

              mapper.Options.Projection.MapCollectionMembers = false;

              var projection = mapper.Project<IListType, OtherListType>().Compile();

              var result = projection(new IListType
              {
            ID = 10,
            Foos = new List<NestedEnumerableSourceType>
              {
            new NestedEnumerableSourceType
            {
              Name = "Test"
            }
              }
              });

              Assert.IsNull(result.Foos);
        }
开发者ID:JulianR,项目名称:ThisMember,代码行数:22,代码来源:ProjectionTests.cs

示例9: NonNullableToNullableWithProjectionsWorksAsExpected

        public void NonNullableToNullableWithProjectionsWorksAsExpected()
        {
            var mapper = new MemberMapper();

              var result = mapper.Project<EnumSourceType, EnumDestinationType>().Compile()(new EnumSourceType { Foo = FooEnum.B });

              Assert.AreEqual(FooEnum.B, result.Foo);
        }
开发者ID:JulianR,项目名称:ThisMember,代码行数:8,代码来源:NullableValueTypesTests.cs

示例10: ProjectionsAffectMaps

        public void ProjectionsAffectMaps()
        {
            var mapper = new MemberMapper();

              mapper.CreateProjection<SourceType, DestinationType>(src => new DestinationType
              {
            FullName = src.FirstName + " " + src.LastName
              });

              var projection = mapper.Project<SourceType, DestinationType>().Compile();

              var source = new SourceType { FirstName = "First", LastName = "Last" };

              var result = projection(source);

              Assert.AreEqual("First Last", result.FullName);

              result = mapper.Map<SourceType, DestinationType>(source);

              Assert.AreEqual("First Last", result.FullName);
        }
开发者ID:JulianR,项目名称:ThisMember,代码行数:21,代码来源:ProjectionCustomMappingsTests.cs

示例11: PagingOnProjectableWorks

        public void PagingOnProjectableWorks()
        {
            var mapper = new MemberMapper();

              var source = new List<SourceType>
              {
            new SourceType
            {
              ID = 10
            },
            new SourceType
            {
              ID = 20
            },
            new SourceType
            {
              ID = 30
            }
              };

              var result = source.AsQueryable().AsCollectionProjectable().Page(mapper.Project<SourceType, DestinationType>(), 0, 2);

              Assert.AreEqual(2, result.Count);
              Assert.AreEqual(10, result.First().ID);
              Assert.AreEqual(20, result.Skip(1).First().ID);
        }
开发者ID:JulianR,项目名称:ThisMember,代码行数:26,代码来源:ProjectableTests.cs

示例12: AsProjectableToListWorks

        public void AsProjectableToListWorks()
        {
            var mapper = new MemberMapper();

              var source = new List<SourceType>
              {
            new SourceType
            {
              ID = 10
            },
            new SourceType
            {
              ID = 20
            }
              };

              var result = source.AsQueryable().AsProjectable().ToList(mapper.Project<SourceType, DestinationType>());

              Assert.IsTrue(source.Select(s => s.ID).SequenceEqual(result.Select(s => s.ID)));
        }
开发者ID:JulianR,项目名称:ThisMember,代码行数:20,代码来源:ProjectableTests.cs

示例13: AsProjectableSingleThrowsWhenMoreThanOne

        public void AsProjectableSingleThrowsWhenMoreThanOne()
        {
            var mapper = new MemberMapper();

              var source = new List<SourceType>
              {
            new SourceType
            {
              ID = 10
            },
            new SourceType
            {
              ID = 20
            }
              };

              var result = source.AsQueryable().AsProjectable().Single(mapper.Project<SourceType, DestinationType>());

              Assert.AreEqual(1, result.ID);
        }
开发者ID:JulianR,项目名称:ThisMember,代码行数:20,代码来源:ProjectableTests.cs

示例14: SimpleProjectionWorks

        public void SimpleProjectionWorks()
        {
            var mapper = new MemberMapper();

              var result = mapper.Project<SourceType, DestinationType>().Compile()(new SourceType { ID = 1 });

              Assert.AreEqual(1, result.ID);
        }
开发者ID:JulianR,项目名称:ThisMember,代码行数:8,代码来源:ProjectionTests.cs

示例15: ProjectionOfListToListWorks

        public void ProjectionOfListToListWorks()
        {
            var mapper = new MemberMapper();

              var projection = mapper.Project<ListType, OtherListType>().Compile();

              var result = projection(new ListType
            {
              Foos = new List<NestedEnumerableSourceType>
              {
            new NestedEnumerableSourceType
            {
              Name = "Test"
            }
              }
            });

              Assert.AreEqual("Test", result.Foos.Single().Name);
        }
开发者ID:JulianR,项目名称:ThisMember,代码行数:19,代码来源:ProjectionTests.cs


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