IFulltext QueryTDocumentSelectTResult Method
Project the results of this query into a new form.
Definition
Namespace: SphinxConnector.FluentApi
Assembly: SphinxConnector (in SphinxConnector.dll) Version: 6.1.0
The current instance.
Assembly: SphinxConnector (in SphinxConnector.dll) Version: 6.1.0
C#
IFulltextQuery<TResult> Select<TResult>(
Expression<Func<TDocument, TResult>> selector
)
VB
Function Select(Of TResult) (
selector As Expression(Of Func(Of TDocument, TResult))
) As IFulltextQuery(Of TResult)Parameters
- selector ExpressionFuncTDocument, TResult
- A transform function to apply to each element.
Type Parameters
- TResult
- The projected type.
Return Value
IFulltextQueryTResultThe current instance.
Example
Suppose you have the following class representing a document in your index:
And you want to select only the name and price of a product:
C#
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; }
}
And you want to select only the name and price of a product:
C#
using (IFulltextSession fulltextSession = fulltextStore.StartSession())
{
var results = fulltextSession.Query<Product>().
Match("a product").
Select(p => new
{
p.Name,
p.Price
}).ToList();
}