|
using System;
namespace Wintellect.Sterling.Database
{
/// <summary>
/// Extensions for the database
/// </summary>
public static class Extensions
{
/// <summary>
/// Extension to register an index
/// </summary>
/// <typeparam name="T">The type of the table</typeparam>
/// <typeparam name="TIndex">The index</typeparam>
/// <typeparam name="TKey">The key</typeparam>
/// <param name="table">The table definition</param>
/// <param name="name">The name of the index</param>
/// <param name="indexer">The indexer</param>
/// <returns>The table</returns>
public static ITableDefinition WithIndex<T,TIndex,TKey>(this ITableDefinition table, string name, Func<T,TIndex> indexer) where T: class, new()
{
((TableDefinition<T,TKey>)table).RegisterIndex(name, indexer);
return table;
}
/// <summary>
/// Extension to register an index
/// </summary>
/// <typeparam name="T">The type of the table</typeparam>
/// <typeparam name="TIndex1">The index</typeparam>
/// <typeparam name="TIndex2">The second index</typeparam>
/// <typeparam name="TKey">The key</typeparam>
/// <param name="table">The table definition</param>
/// <param name="name">The name of the index</param>
/// <param name="indexer">The indexer</param>
/// <returns>The table</returns>
public static ITableDefinition WithIndex<T, TIndex1, TIndex2, TKey>(this ITableDefinition table, string name, Func<T, Tuple<TIndex1,TIndex2>> indexer)
where T : class, new()
{
((TableDefinition<T, TKey>)table).RegisterIndex(name, indexer);
return table;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.