public IEnumerable <ApiResource> Search(string keywords, int pageIndex, int pageSize, out int totalCount)
        {
            using (var connection = _options.DbProviderFactory.CreateConnection())
            {
                connection.ConnectionString = _options.ConnectionString;

                DynamicParameters pairs = new DynamicParameters();
                pairs.Add("keywords", "%" + keywords + "%");

                var countsql = "select count(1) from ApiResources where Name like @keywords or DisplayName like @keywords or Description like @keywords";
                totalCount = connection.ExecuteScalar <int>(countsql, pairs, commandType: CommandType.Text);

                if (totalCount == 0)
                {
                    return(null);
                }

                var apis = connection.Query <Entities.ApiResource>(_options.GetPageQuerySQL("select * from ApiResources where Name like @keywords or DisplayName like @keywords or Description like @keywords", pageIndex, pageSize, totalCount, "", pairs), pairs, commandTimeout: _options.CommandTimeOut, commandType: CommandType.Text);
                if (apis != null)
                {
                    return(apis.Select(c => c.ToModel()));
                }
                return(null);
            }
        }
        public IEnumerable <PersistedGrant> Search(string keywords, int pageIndex, int pageSize, out int totalCount)
        {
            using (var connection = _options.DbProviderFactory.CreateConnection())
            {
                connection.ConnectionString = _options.ConnectionString;

                DynamicParameters pairs = new DynamicParameters();
                pairs.Add("keywords", "%" + keywords + "%");

                var countsql = $"select count(1) from persistedgrants where {left}Key{right} like @keywords or ClientId like @keywords or SubjectId like @keywords OR {left}Type{right} like @keywords";
                totalCount = connection.ExecuteScalar <int>(countsql, pairs, commandType: CommandType.Text);

                if (totalCount == 0)
                {
                    return(null);
                }

                var clients = connection.Query <Entities.PersistedGrant>(_options.GetPageQuerySQL($"select * from persistedgrants where {left}Key{right} like @keywords or ClientId like @keywords or SubjectId like @keywords OR {left}Type{right} like @keywords", pageIndex, pageSize, totalCount, $"order by {left}Key{right}", pairs), pairs, commandTimeout: _options.CommandTimeOut, commandType: CommandType.Text);
                if (clients != null)
                {
                    return(clients.Select(c => c.ToModel()));
                }
                return(null);
            }
        }