<commit_before>﻿/*
 * Copyright (c) <NAME>.  All rights reserved.
 * see license.txt
 */

using System.Collections.Generic;
using System.Data;
using System.Linq;
using Thinktecture.IdentityServer.Models;

namespace Thinktecture.IdentityServer.Repositories.Sql
{
    public class RelyingPartyRepository : IRelyingPartyRepository
    {
        public bool TryGet(string realm, out RelyingParty relyingParty)
        {
            relyingParty = null;

            using (var entities = IdentityServerConfigurationContext.Get())
            {
                var match = (from rp in entities.RelyingParties
                             where rp.Realm.Equals(realm, System.StringComparison.OrdinalIgnoreCase)
                             select rp)
                            .FirstOrDefault();

                if (match != null)
                {
                    relyingParty = match.ToDomainModel();
                    return true;
                }
            }

            return false;
        }

        #region Management<commit_msg>Returned to best match RP search<commit_after>﻿/*
 * Copyright (c) <NAME>.  All rights reserved.
 * see license.txt
 */

using System.Collections.Generic;
using System.Data;
using System.Linq;
using Thinktecture.IdentityServer.Models;

namespace Thinktecture.IdentityServer.Repositories.Sql
{
    public class RelyingPartyRepository : IRelyingPartyRepository
    {
        public bool TryGet(string realm, out RelyingParty relyingParty)
        {
            relyingParty = null;

            using (var entities = IdentityServerConfigurationContext.Get())
            {
                var match = (from rp in entities.RelyingParties
                             where rp.Realm.StartsWith(realm)
                             orderby rp.Realm descending
                             select rp)
                            .FirstOrDefault();

                if (match != null)
                {
                    relyingParty = match.ToDomainModel();
                    return true;
                }
            }

            return false;
        }

        #region Management
{'fraction_non_alphanumeric': 0.07146215326751293, 'fraction_numerical': 0.0, 'mean_word_length': 1.563855421686747, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3113984', 'n_tokens_mistral': 547, 'n_tokens_neox': 513, 'n_words': 124}