SemWeb.SelectableSource

SemWeb : SemWeb Namespace
SelectableSource Interface

An interface implemented by RDF sources that supports Select operations.

public interface SelectableSource : , StatementSource

#### Remarks

Classes that implement this interface support the SemWeb.SelectableSource.Contains(SemWeb.Statement) which returns whether any statement matches the given statement template, and SemWeb.SelectableSource.Select(SemWeb.Statement,SemWeb.StatementSink) and SemWeb.SelectableSource.Select(SemWeb.SelectFilter,SemWeb.StatementSink).

## Members

### Methods

| Contains (Resource) : bool Tests whether a resource is mentioned in the data source.
| Contains (Statement) : bool Returns whether the store contains a statement, or any statement that matches the template.
| Select (SelectFilter, StatementSink) Queries the story for matching statements, with advanced options, and writes the statements to a SemWeb.StatementSink.
| Select (Statement, StatementSink) Queries the story for matching statements, and writes the statements to a SemWeb.StatementSink.

## Member Details

### Contains Method

public bool Contains (Statement template)

Returns whether the store contains a statement, or any statement that matches the template.

#### Parameters

template
  The statement to search for, or a statement template.

#### Returns

`true` if the store contains the statement or any statement matching the template.

#### Remarks

The following expression tests for the existence of any rdf:type predicate in the store.

C# Example
    store.Contains(new Statement(null, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", null));

### Select Method

public void Select (Statement template, StatementSink sink)

Queries the story for matching statements, and writes the statements to a SemWeb.StatementSink.

#### Parameters

template
  A statement template. Use SemWeb.Statement.All to select all statements in the store, or a statement with `null` fields to select statements that match the non-`null` parts of the statement.
sink
  A StatementSink to which each matching statement will be added.

#### Remarks

Each statement in the store matching template is added to sink with a call to SemWeb.StatementSink.Add(SemWeb.Statement). If the call to Add returns `false`, the select operation is aborted and returns immediately.

template is a statement template, which means any field in template may be `null`, and those fields are excluded from the statement filter. For example, setting the Subject and Predicate fields but leaving the Object and Meta fields `null` will match all statements in the store that have the given Subject and Predicate, and anything in their Object and Meta fields.

The following expression writes out all statements with the `rdf:type` predicate to standard output.

C# Example
    using (StatementSink sink = new N3Writer(Console.Out)) {
        store.Select(new Statement(null, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", null), sink);
    }

### Select Method

public void Select (SelectFilter filter, StatementSink sink)

Queries the story for matching statements, with advanced options, and writes the statements to a SemWeb.StatementSink.

#### Parameters

filter
  A filter specifying what statements to return.
sink
  A StatementSink to which each matching statement will be added.

#### Remarks

This overload of Select is used to query for statements matching many resources.

The following expression writes out all statements with either of two entities as the subject.

C# Example
    Entity a = "http://www.example.org/entityA";
    Entity b = "http://www.example.org/entityB";

    using (StatementSink sink = new N3Writer(Console.Out)) {
        store.Select(
            new SelectFilter(new Entity[] { a , b }, null, null),
            sink);
    }

### Contains Method

public bool Contains (Resource resource)

Tests whether a resource is mentioned in the data source.

#### Parameters

resource
  A Resource (an entity, bnode, or literal value).

#### Returns

A boolean value indicating whether the resource is mentioned in the store.

#### Remarks

None.