Affecto.IdentityManagement.Store.EntityFramework.Queries.UserByAccountQuery.Execute C# (CSharp) Method

Execute() public method

public Execute ( string accountName, AccountType accountType ) : User
accountName string
accountType AccountType
return User
        public User Execute(string accountName, AccountType accountType)
        {
            return queryBuilder.IncludeAll()
                .SingleOrDefault(u => u.Accounts.Any(a => a.Name.Equals(accountName, StringComparison.OrdinalIgnoreCase) && a.Type == accountType));
        }

Usage Example

        public string GetPassword(string accountName)
        {
            var query = new UserByAccountQuery(dbContext.Users);
            Model.User user = query.Execute(accountName, Model.AccountType.Password);

            if (user == null)
            {
                throw new EntityNotFoundException("Account", accountName);
            }

            Model.Account account = user.GetAccount(Model.AccountType.Password, accountName);
            return account.Password;
        }
All Usage Examples Of Affecto.IdentityManagement.Store.EntityFramework.Queries.UserByAccountQuery::Execute