public static LogEntity GetLogsByUserID(string userID, int tops = 1) { string tablename = "select top " + tops + " a.* from UsersLog a left join M_Users b on a.UserID =b.UserID "; string sqlwhere = " where 1=1 "; if (!string.IsNullOrEmpty(userID)) { sqlwhere += " and a.userID='" + userID + "'"; } DataTable dt = LogDAL.GetDataTable(tablename + sqlwhere + " order by a.AutoID desc "); LogEntity model = new LogEntity(); foreach (DataRow dr in dt.Rows) { model.FillData(dr); } return(model); }