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 System.Linq.Expressions;
12 : using Cqrs.Entities;
13 :
14 : namespace Cqrs.MongoDB.DataStores.Indexes
15 : {
16 : /// <summary>
17 : /// An index for MongoDB.
18 : /// </summary>
19 : /// <typeparam name="TEntity">The <see cref="Type"/> of <see cref="IEntity"/> this index is for.</typeparam>
20 : public abstract class MongoDbIndex<TEntity>
21 1 : {
22 : /// <summary>
23 : /// Indicates if the index enforces unique values. Defaults to false.
24 : /// </summary>
25 : public bool IsUnique { get; protected set; }
26 :
27 : /// <summary>
28 : /// Indicates if the index is in ascending order or descending. Defaults to true meaning ascending order.
29 : /// </summary>
30 : public bool IsAcending { get; protected set; }
31 :
32 : /// <summary>
33 : /// The name of the index. Default to the class name removing any instances of "Index" and "MongoDbIndex" from the name.
34 : /// </summary>
35 : public string Name { get; protected set; }
36 :
37 : /// <summary>
38 : /// The selectors that the index is comprised of.
39 : /// </summary>
40 : public IEnumerable<Expression<Func<TEntity, object>>> Selectors { get; protected set; }
41 :
42 : /// <summary>
43 : /// Instantiate a new instance of <see cref="MongoDbIndex{TEntity}"/>.
44 : /// </summary>
45 1 : protected MongoDbIndex()
46 : {
47 : IsUnique = false;
48 : IsAcending = true;
49 : Name = GetType()
50 : .Name
51 : .Replace("MongoDbIndex", string.Empty)
52 : .Replace("Index", string.Empty);
53 : }
54 : }
55 : }
|