Class RedisCollection<T>
Collection of items in Redis, can be queried using it's fluent interface.
Inheritance
Implements
Inherited Members
Namespace: Redis.OM.Searching
Assembly: Redis.OM.dll
Syntax
public class RedisCollection<T> : IRedisCollection<T>, IOrderedQueryable<T>, IOrderedQueryable, IQueryable<T>, IEnumerable<T>, IQueryable, IEnumerable, IAsyncEnumerable<T>
Type Parameters
Name | Description |
---|---|
T | The type being stored in Redis. |
Constructors
| Improve this Doc View SourceRedisCollection(IRedisConnection, Int32)
Initializes a new instance of the RedisCollection<T> class.
Declaration
public RedisCollection(IRedisConnection connection, int chunkSize = 100)
Parameters
Type | Name | Description |
---|---|---|
IRedisConnection | connection | Connection to Redis. |
System.Int32 | chunkSize | Size of chunks to pull back during pagination, defaults to 100. |
Properties
| Improve this Doc View SourceChunkSize
Gets the size of chunks to use when paginating.
Declaration
public int ChunkSize { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
ElementType
Declaration
public Type ElementType { get; }
Property Value
Type | Description |
---|---|
System.Type |
Expression
Declaration
public Expression Expression { get; }
Property Value
Type | Description |
---|---|
System.Linq.Expressions.Expression |
Provider
Declaration
public IQueryProvider Provider { get; }
Property Value
Type | Description |
---|---|
System.Linq.IQueryProvider |
StateManager
Gets manages the state of the items queried from Redis.
Declaration
public RedisCollectionStateManager StateManager { get; }
Property Value
Type | Description |
---|---|
RedisCollectionStateManager |
Methods
| Improve this Doc View SourceAny(Expression<Func<T, Boolean>>)
Checks to see if anything matching the expression exists.
Declaration
public bool Any(Expression<Func<T, bool>> expression)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<T, System.Boolean>> | expression | the expression to be matched. |
Returns
Type | Description |
---|---|
System.Boolean | Whether anything matching the expression was found. |
Delete(T)
Deletes the item from Redis.
Declaration
public async Task Delete(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to be deleted. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous operation. |
FindById(String)
finds an item by it's ID.
Declaration
public T FindById(string id)
Parameters
Type | Name | Description |
---|---|---|
System.String | id | the id to lookup. |
Returns
Type | Description |
---|---|
T | the item if it's present. |
FindByIdAsync(String)
finds an item by it's ID.
Declaration
public async Task<T> FindByIdAsync(string id)
Parameters
Type | Name | Description |
---|---|---|
System.String | id | the id to lookup. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | the item if it's present. |
GetAsyncEnumerator(CancellationToken)
Declaration
public IAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerator<T> |
GetEnumerator()
Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<T> |
Insert(T)
Inserts an item into redis.
Declaration
public string Insert(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | an item. |
Returns
Type | Description |
---|---|
System.String | the key. |
InsertAsync(T)
Inserts an item into redis.
Declaration
public async Task<string> InsertAsync(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | an item. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.String> | the key. |
Save()
Saves the current state of the collection, overriding what was initially materialized.
Declaration
public void Save()
SaveAsync()
Saves the current state of the collection, overriding what was initially materialized.
Declaration
public async ValueTask SaveAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask | a value task. |
Update(T)
Updates the provided item in Redis. Document must have a property marked with the RedisIdFieldAttribute.
Declaration
public async Task Update(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to update. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous operation. |
Explicit Interface Implementations
| Improve this Doc View SourceIEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |