Skip to content

Contracts

Ambystech.Neo4j.Repository.Contracts is a lightweight package that defines the types the repository reads and writes. Domain projects can reference it without pulling in the Neo4j driver.

Abstract base class for every entity stored in the graph. It provides the audit fields the repository maintains automatically.

PropertyTypeSet by
Idstring?Neo4j elementId(n) on read
CreatedAtDateTime?CreateAsync
UpdatedAtDateTime?UpdateAsync
DeletedAtDateTime?DeleteAsync (soft delete)

Queries filter DeletedAt IS NULL by default.

Marks a property as searchable, as a Neo4j relationship, or both. Three overloads cover the common cases:

// 1. Simple searchable scalar field
[GraphField("name", isSearchable: true)]
public string Name { get; set; }
// 2. Searchable relationship property
[GraphField("likedPosts",
isSearchable: true,
relationshipTypes: new[] { "LIKE" },
targetNodeLabel: "Post",
direction: Direction.Outgoing)]
public List<Post> LikedPosts { get; set; }
// 3. Relationship-only (e.g. reverse link or count-only)
[GraphField(
relationshipTypes: new[] { "LIKE" },
targetNodeLabel: "Post",
direction: Direction.Incoming,
isCountOnly: true)]
public int LikeCount { get; set; }

Key fields: FieldName, IsSearchable, IsRelationship, RelationshipTypes[], TargetNodeLabel, Direction, IsCountOnly.

Pagination and filter contract passed to the repository’s search methods.

PropertyPurpose
TextSearchFree-text filter applied to searchable fields
Page1-based page number
PageSizePage size
SkipComputed offset ((Page - 1) * PageSize)
IncludeDeletedBypass the soft-delete filter
OrderByFieldProperty name to sort by
DescendingSort direction

Wrapper returned by paginated queries.

public class SearchResult<T>
{
public IEnumerable<T> Results { get; set; }
public long TotalResults { get; set; }
}