Copying between two classes (equivalent to deep copy ),

Source: Internet
Author: User
Code
This method works well in the case of changes to the LINQ clause.

(Lgd_inn) toolbox. propertycopy (objinn, R );

/// <Summary>
/// Attribute assignment between two instances
/// </Summary>
/// <Param name = "obj1"> </param>
/// <Param name = "obj2"> </param>
/// <Returns> </returns>
Public static object propertycopy (Object objsrc, object objdest)
{
Type soutype = objsrc. GetType ();
Type tartype = objdest. GetType ();
Propertyinfo [] Pis = soutype. getproperties (bindingflags. Public | bindingflags. instance );
If (null! = PIS)
{
Foreach (propertyinfo PI in PIS)
{
String propertyname = pi. Name;
Propertyinfo Pit = tartype. getproperty (propertyname );
If (pit! = NULL)
{
Pit. setvalue (objdest, Pi. getvalue (objsrc, null), null );
}
}
}
Return objdest;

}

 

 

This method is useful when you modify a value in LINQ because a value is obtained first and then modified. This method is not required.

 

When bound to the sqldatasource control, you can achieve better performance by setting the datasourcemode attribute to datareader.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.