class UserClass{
#region Class properties which are binding from DB
.
.
.
#endregion
#region Constructor Methods
public UserClass(int _iUser_id)
{
// of course this is wrong but how can i quickly se开发者_JAVA百科t properties
// which are coming from DB by extension method over context class?
this = DAO.context.GetById<UserClass>(_iUser_id);
}
#endregion
}
You need to set the properties manually.
If you really want to, you could use reflection or expression trees to loop through the properties, but it's probably not worth it.
You could use a static method instead of a constructor:
public static UserClass GetById(int userId) {
return DAO.context.GetById<UserClass>(userId);
}
精彩评论