public Account getAccountByUserName(string username) { db = new LinQDataContext(); var result = db.getAccountByUserName(username).FirstOrDefault(); if (result != null) { Account account = new Account(); account.AccountId = result.AccountId; account.Password = result.Password; account.Role = result.Role; account.UserName = result.UserName; return(account); } return(null); }