UsingSystem. Collections. Generic;
UsingSystem. Data. sqlclient;
UsingSystem. Data;
UsingSystem;
Namespace Npetshop. Domain
{
/* **************************************** **********************************
*
* Function: product entity class
* Author: Li Weiwei
* Date: 2011-5-28
* Description: 11111111111111111111111111
**************************************** ********************************* */
[Serializable]
Public Class Productentity
{
# Region Attribute
/// <Summary>
/// Gets or sets the value of the ID field from the auto-incrementing column system. int32
/// Database Type length: int size: 4 precision: 10
/// </Summary>
[Column ( " ID " )]
Public System. int32 ID { Get ; Set ;}
/// <Summary>
/// Gets or sets the value of the Name field system. String
/// Database Type length: varchar size: 50
/// </Summary>
[Column ( " Name " )]
Public System. string name { Get ; Set ;}
/// <Summary>
/// Gets or sets the value of The USERID field system. int32
/// Database Type length: int size: 4 precision: 10
/// </Summary>
[Column ( " Userid " )]
Public System. int32 userid { Get ; Set ;}
# Endregion
# Region Constructor
/// <Summary>
/// Constructor
/// </Summary>
/// <Param name = "name"> Name </Param>
/// <Param name = "userid"> Userid </Param>
Public Productentity (system. string name, system. int32 userid)
{
This . Name = Name;
This . Userid = Userid;
}
/// <Summary>
/// Constructor
/// </Summary>
Public Productentity ()
{
This . Name = Null ;
This . Userid = 0 ;
}
# Endregion
}
}
//Features
UsingSystem;
UsingSystem. Collections. Generic;
UsingSystem. text;
UsingSystem. Data;
Namespace Npetshop. Domain
{
/// <Summary>
/// Associate class attributes with columns in the database table.
/// </Summary>
[Attributeusage (attributetargets. Property)]
Public Sealed Class Columnattribute: system. Attribute
{
/// <Summary>
/// Obtains or sets the column name.
/// </Summary>
Public String Columnname { Get ; Private Set ;}
/// <Summary>
/// Obtains or sets the column title.
/// </Summary>
Public String Columncaption { Get ; Private Set ;}
/// <Summary>
/// Obtains or sets the column type.
/// </Summary>
Public Sqldbtype columntype { Get ; Private Set ;}
/// <Summary>
/// Initializes a new instance of the magicstar. entity. columnattribute class.
/// </Summary>
/// <Param name = "columncaption"> Table or view title. </Param>
/// <Param name = "columnname"> The name of the table or view. </Param>
/// <Param name = "columntype"> Type. </Param>
Public Columnattribute ( String Columnname, String Columncaption, sqldbtype columntype)
{
Columnname = Columnname;
Columncaption = Columncaption;
Columntype = Columntype;
}
/// <Summary>
/// Initializes a new instance of the magicstar. entity. columnattribute class.
/// </Summary>
/// <Param name = "columncaption"> Table or view title. </Param>
/// <Param name = "columnname"> The name of the table or view. </Param>
/// <Param name = "columntype"> Type. </Param>
Public Columnattribute ( String Columnname)
{
Columnname = Columnname;
}
}
}
/// Implementation
Productentity _ roductentity = New Productentity ();
_ Roductentity. ID = 1 ;
_ Roductentity. Name = " 2 " ;
type = _ roductentity. getType ();
propertyinfo [] properties = type. getproperties ();
foreach (propertyinfo property in Properties)
{< br> response. write (type. getproperty (property. name ). getvalue (_ roductentity, null ));
response. write (property. name + " " );
}