Line data Source code
1 : #region Copyright
2 : // // -----------------------------------------------------------------------
3 : // // <copyright company="Chinchilla Software Limited">
4 : // // Copyright Chinchilla Software Limited. All rights reserved.
5 : // // </copyright>
6 : // // -----------------------------------------------------------------------
7 : #endregion
8 :
9 : using System;
10 : using System.Collections.Generic;
11 : using Cqrs.Entities;
12 :
13 : namespace Cqrs.Mongo.DataStores.Indexes
14 : {
15 : /// <summary>
16 : /// An index for MongoDB.
17 : /// </summary>
18 : /// <typeparam name="TEntity">The <see cref="Type"/> of <see cref="IEntity"/> this index is for.</typeparam>
19 : public abstract class MongoIndex<TEntity>
20 1 : {
21 : /// <summary>
22 : /// Indicates if the index enforces unique values. Defaults to false.
23 : /// </summary>
24 : public bool IsUnique { get; protected set; }
25 :
26 : /// <summary>
27 : /// Indicates if the index is in ascending order or descending. Defaults to true meaning ascending order.
28 : /// </summary>
29 : public bool IsAcending { get; protected set; }
30 :
31 : /// <summary>
32 : /// The name of the index. Default to the class name removing any instances of "Index" and "MongoIndex" from the name.
33 : /// </summary>
34 : public string Name { get; protected set; }
35 :
36 : /// <summary>
37 : /// The selectors that the index is comprised of.
38 : /// </summary>
39 : public IEnumerable<System.Linq.Expressions.Expression<Func<TEntity, object>>> Selectors { get; protected set; }
40 :
41 : /// <summary>
42 : /// Instantiate a new instance of <see cref="MongoIndex{TEntity}"/>.
43 : /// </summary>
44 1 : protected MongoIndex()
45 : {
46 : IsUnique = false;
47 : IsAcending = true;
48 : Name = GetType()
49 : .Name
50 : .Replace("MongoIndex", string.Empty)
51 : .Replace("Index", string.Empty);
52 : }
53 : }
54 : }
|