public IEnumerable<UserProfile> GetAllUserProfiles() { var query = @"Select {0} from UserProfile".FormatWith(sqlFields); using (var sql = new SqlHelper().OpenConnection()) { return sql.Query<UserProfile>(query); } }
public UserProfile GetUserProfileByUserName(string userName) { var query = @"Select {0} from UserProfile Where UserName = @UserName".FormatWith(sqlFields); using (var sql = new SqlHelper().OpenConnection()) { var userProfiles = sql.Query<UserProfile>(query, new { UserName = userName }); if (userProfiles.Any()) { return userProfiles.First(); } } return null; }