public MongoCollection(Mongo client, string colName) { this.client = client; collection = client.Database.GetCollection <T>(colName); List <PropertyInfo> props = typeof(T).GetProperties().Where(x => MongoIndexAttribute.GetIndexType(x) != IndexType.None).ToList(); foreach (PropertyInfo i in props) { IndexType t = MongoIndexAttribute.GetIndexType(i); ///collection.Indexes.CreateOne(new IndexKeysDefinitionBuilder<T>().Ascending() } }
// public static bool DeleteObject(string id) { Mongo.DeleteObject(x => x.ObjectID == id); return(true); }
protected static List <T> GetObjects(Expression <Func <T, bool> > condition) { return(Mongo.RetrieveObjects(condition)); }
//Multiple public static List <T> GetObjects() { return(Mongo.RetrieveObjects()); }
//Single public static T GetObject(string id) { return(Mongo.RetrieveObject(x => x.ObjectID == id)); }
public bool Update() { Mongo.ReplaceObject(x => x.ObjectID == ObjectID, (T)this); return(true); }
//Manipulation public bool Insert() { Mongo.InsertObject((T)this); return(true); }
public MongoProvider(MongoSettings settings) { Settings = settings; mongo = new MongoDB.Mongo(settings); }