public string GetUserName(string userId) { using (UserEntities db = new UserEntities()) { string result = (from s in db.AspNetUsers where s.Id == userId select s.UserName).FirstOrDefault(); return(result); } }
//取得訂單中的使用者暱稱 public string GetUserName() { //使用ProductComment類別中的UserId到AspNetUsers資料表中搜尋出UserName using (Models.UserEntities db = new UserEntities()) { var result = db.AspNetUsers.Where(p => p.Id == this.UserId).FirstOrDefault().UserName; //回傳找到的UserName return(result); } }
/// <summary> /// 傳入user id清單,回傳user name清單 /// </summary> /// <param name="userIds"></param> /// <returns></returns> public static List <string> GetUserNames(List <string> userIds) { List <string> userNames; using (UserEntities db = new UserEntities()) { //UserId List映射UserName List userNames = userIds.Select(userId => (from s in db.AspNetUsers where s.Id == userId select s.UserName).FirstOrDefault()).ToList(); } return(userNames); }
/// <summary> /// 取得訂單中的使用者暱稱 Gets the name of the user. /// </summary> /// <param name="userId">The user identifier.</param> /// <returns>回傳 使用者暱稱</returns> public string GetUserName(string userId) { using (Models.UserEntities db = new UserEntities()) { var result = db.AspNetUsers .Where(w => w.Id == UserId) .Select(s => s.UserName).FirstOrDefault(); //回傳找到的UserName return(result); } }
//取得訂單中的 使用者暱稱 public string GetUrderName() { //使用Order類別中的UserId到AspNetUsers資料表中搜尋出UserName using (Models.UserEntities db = new UserEntities()) { var result = (from s in db.AspNetUsers where s.Id == this.UserId select s.UserName).FirstOrDefault(); //回傳找到的UserName return(result); } }