private static UserModel ConvertToUserModel(userRow row)
{
if (row == null) return null;
UserModel data = new UserModel()
{
ID = row.ID,
UserGroupID = row.UserGroupID,
UserName = row.UserName,
Password = row.Password,
LastLoginTime = row.IsLastLoginTimeNull() ? null : (DateTime?)row.LastLoginTime,
UpdateAt = row.UpdateAt,
IsDeleted = row.IsDeleted,
IsDefault = row.IsDefault
};
return data;
}
/// <summary>
/// 获取最近登录的5名用户
/// </summary>
/// <returns></returns>
public static List<UserModel> GetRecentlyLoginUsers()
{
string sql = @"select `ID`, `UserGroupID`, `UserName`, `Password`, `LastLoginTime`, `UpdateAt`, `CreateAt`, `IsDeleted`, `IsDefault`, `Description` from User where LastLoginTime is not null order by LastLoginTime desc limit 5";
List<UserModel> data = DBHelper.Query<userDataTable>(sql).Select(r => { return ConvertToUserModel(r); }).ToList();
return data;
}
List<UserModel> data = DBHelper.Query<userDataTable>(sql).Select(r => { return ConvertToUserModel(r); }).ToList();
Select(r => { return ConvertToUserModel(r); }).ToList(); //妙哉
linq查询多个实体类数据
© 版权声明
THE END
暂无评论内容