How to decorate a class item to be an index and get the same as using ensureIndex?
问题 I'd like to define in class declaration which items are index, something like: public class MyClass { public int SomeNum { get; set; } [THISISANINDEX] public string SomeProperty { get; set; } } so to have the same effect as ensureIndex("SomeProperty") Is this possible? 回答1: I think this is a nice idea, but you have to do this yourself, there's no built-in support for it. If you have an access layer you can do it in there. You'd need an attribute class, something like this; public enum