Click or drag to resize
Projection Class
Provides methods to project properties into new values. The methods are intended to be used with the methods provided by the IFulltextQueryTDocument interface.
Inheritance Hierarchy
SystemObject
  SphinxConnector.FluentApiProjection

Namespace: SphinxConnector.FluentApi
Assembly: SphinxConnector (in SphinxConnector.dll) Version: 3.12.6
Syntax
public static class Projection

The Projection type exposes the following members.

Methods
  NameDescription
Public methodStatic memberAvgTSource
Computes the average of a sequence of values.
Public methodStatic memberCount
Computes the number of occurences of a value in a sequence of values.
Public methodStatic memberCountTResult
Computes the number of occurences of a value in a sequence of values.
Public methodStatic memberCountDistinctTSource
Computes the number of distinct occurences of a value in a sequence of values.
Public methodStatic memberMaxTResult
Computes the maximum of a sequence of values.
Public methodStatic memberMinTResult
Computes the minimum of a sequence of values.
Public methodStatic memberSumTResult
Computes the sum of a sequence of values.
Top
Examples
Suppose you have the following class representing a document in your index:
public class Product
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public decimal Price { get; set; }
    public int CategoryId { get; set; }
    public int VendorId { get; set; }
    public int Weight { get; set; }
}

The following code computes the number of products in a category that match a query:
using (IFulltextSession fulltextSession = fulltextStore.StartSession())
{
    var results = fulltextSession.Query<Product>().
                                  Match("a query").
                                  GroupBy(p => p.CategoryId).
                                  Select(p => new
                                  {
                                      p.CategoryId,
                                      ProductsInCategory = Projection.Count()
                                  }).
                                  ToList();
}
See Also