Created
December 5, 2012 20:19
-
-
Save efbenson/4219145 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//CODE in project | |
Facility.AddIndex(f => f.Locations); | |
LookupMetadata.AddIndex(f => new {f.TypeFullName, f.Data.DisplayText}); | |
//CODE in library | |
public void AddIndex(Expression<Func<T, object>> indexKey, string indexName = null, bool isUnique = false, bool descending = false) | |
{ | |
if (string.IsNullOrEmpty(indexName)) | |
{ | |
indexName = typeof(T).Name + "_Index_" + ObjectId.GenerateNewId(); | |
} | |
// TODO: Make indexKey into a CSV string? | |
var keys = indexKey...... | |
var keys = IndexKeys.Ascending(keys); | |
var options = IndexOptions.SetName(indexName).SetUnique(isUnique); | |
this.GetMongoCollection().CreateIndex(keys, options); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment