HTML5¼¼Êõ

C# ¿ìËÙ¸ßЧÂʸ´ÖƶÔÏóÁíÒ»ÖÖ·½Ê½ ±í´ïʽÊ÷ - Emrys5(2)

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2017-04-06 14:00 ÎÒÒªÆÀÂÛ( )

TransExpV2TIn, TOut { FuncTIn, TOut cache = GetFunc(); private static FuncTIn, TOut GetFunc(){ParameterExpression parameterExpression = Expression.Parameter( );List MemberBinding memberBindingList =

TransExpV2<TIn, TOut> { Func<TIn, TOut> cache = GetFunc(); private static Func<TIn, TOut> GetFunc() { ParameterExpression parameterExpression = Expression.Parameter(); List<MemberBinding> memberBindingList = new List<MemberBinding>(); foreach (var item in typeof(TOut).GetProperties()) { MemberExpression property = Expression.Property(parameterExpression, typeof(TIn).GetProperty(item.Name)); MemberBinding memberBinding = Expression.Bind(item, property); memberBindingList.Add(memberBinding); } MemberInitExpression memberInitExpression = Expression.MemberInit(Expression.New(typeof(TOut)), memberBindingList.ToArray()); Expression<Func<TIn, TOut>> lambda = Expression.Lambda<Func<TIn, TOut>>(memberInitExpression, new ParameterExpression[] { parameterExpression }); return lambda.Compile(); } public static TOut Trans(TIn tIn) { return cache(tIn); } }

 

µ÷ÓãºStudentSecond ss= TransExpV2<Student, StudentSecond>.Trans(s);

µ÷ÓÃÒ»°ÙÍò´ÎºÄʱ£º107ºÁÃë

ºÄʱԶԶµÄСÓÚʹÓÃautomapperµÄ338ºÁÃë¡£ 

 

4¡¢×ܽá

´ÓÒÔÉϵIJâÊԺͷÖÎö¿ÉÒÔºÜÈÝÒ׵óö£¬Óñí´ïʽÊ÷ÊÇ¿ÉÒԴﵽЧÂÊÓëÊéд·½Ê½¶þÕ߼汸µÄ·½·¨Ö®Ò»£¬×ÜÖ®±È´«Í³µÄÐòÁл¯ºÍ·´Éä¸ü¼ÓÓÅÐã¡£

×îºóÍû¶Ô¸÷λÓÐËù°ïÖú£¬±¾ÎÄÔ­´´£¬»¶Ó­ÅÄשºÍÍƼö¡£  

 

¡¡

1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

Ïà¹ØÎÄÕÂ
  • ASP.NET Core MVCѹËõÑùʽ¡¢½Å±¾¼°×ÜÊǸ´ÖÆÎļþµ½Êä³öĿ¼ - JeffckyWang

    ASP.NET Core MVCѹËõÑùʽ¡¢½Å±¾¼°×ÜÊǸ´ÖÆÎļþµ½Êä³öĿ¼ - Jeffcky

    2017-02-02 12:07

  • ÀûÓÃKaptcha.jarÉú³ÉͼƬÑéÖ¤Â루ÒÔÏÂÔ´Âë¿ÉÒÔÖ±½Ó¸´ÖƲ¢×Ô¶¨ÒåÐ޸ģ© - ÍòÔª»§jhg

    ÀûÓÃKaptcha.jarÉú³ÉͼƬÑéÖ¤Â루ÒÔÏÂÔ´Âë¿ÉÒÔÖ±½Ó¸´ÖƲ¢×Ô¶¨ÒåÐÞ¸Ä

    2017-01-18 10:00

  • ΢ÐÅС³ÌÐò¿ª·¢¡ª¿ìËÙÕÆÎÕ×é¼þ¼°APIµÄ·½·¨ - iyifei

    ΢ÐÅС³ÌÐò¿ª·¢¡ª¿ìËÙÕÆÎÕ×é¼þ¼°APIµÄ·½·¨ - iyifei

    2017-01-05 16:02

  • ¡¾µÚ¶þƪ¡¿ASP.NET MVC¿ìËÙÈëÃÅÖ®Êý¾Ý×¢½â£¨MVC5+EF6£© - ÈýÉúʯÉÏ

    ¡¾µÚ¶þƪ¡¿ASP.NET MVC¿ìËÙÈëÃÅÖ®Êý¾Ý×¢½â£¨MVC5+EF6£© - ÈýÉúʯÉÏ

    2016-12-27 13:00

ÍøÓѵãÆÀ
Ñ