Esempio n. 1
0
        public void Mapp_Nested()
        {
            var newH = YmtEntityMappingDSL
                       .CreateMap <C, H>(true)

                       .ForMember(e => e.HA, _e => _e.MapFrom(__ => __.A))
                       //.ForMember(e => e.HD, _e => _e.MapFrom(__ => __.DT.Dt))
                       .ForSourceMember(e => e.DT, e => e.Ignore())
                       .MapTo(new C {
                A = 100, DT = new D {
                    Dt = TT.F
                }
            });

            Assert.AreEqual(100, newH.HA);
            Assert.AreEqual(1, newH.HD);
        }
Esempio n. 2
0
        public void Mapp_YmtMapp_Test()
        {
            var dt = DateTime.Now;
            var v  = dt.ToString();
            var _a = YmtEntityMappingDSL
                     .CreateMap <B, A>(true)
                     .TypeConvert(b => new A()
            {
                Field2 = Convert.ToDateTime(b.Field4)
            })
                     .ForMember(a => a.Field3, b => b.MapFrom(_b => _b.Field3))
                     .ForMember(a => a.Field2, b => b.MapFrom(_b => _b.Field4))
                     .MapTo(new B {
                Field3 = 10, Field2 = dt, Field4 = "S"
            });

            //YmtSystemAssert.AssertArgumentEquals(_a,null, "映射失败");
            Assert.AreEqual(dt.Second, _a.Field2.Second);
        }