ElasticLinq.Response.Materializers.CountElasticMaterializer.Materialize C# (CSharp) Method

Materialize() public method

Materialize the result count for a given response.
public Materialize ( ElasticLinq.Response.Model.ElasticResponse response ) : object
response ElasticLinq.Response.Model.ElasticResponse The to obtain the count value from.
return object
        public object Materialize(ElasticResponse response)
        {
            if (response.hits.total < 0)
                throw new ArgumentOutOfRangeException("response", "Contains a negative number of hits.");

            return Convert.ChangeType(response.hits.total, returnType);
        }
    }

Usage Example

        public void CountMaterializerThrowsForNegativeCount()
        {
            var response = new ElasticResponse { hits = new Hits { hits = new List<Hit>(), total = -1 } };
            var materializer = new CountElasticMaterializer(typeof(int));

            Assert.Throws<ArgumentOutOfRangeException>(() => materializer.Materialize(response));
        }
All Usage Examples Of ElasticLinq.Response.Materializers.CountElasticMaterializer::Materialize