Пример #1
0
        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()
            }
        }
Пример #2
0
 //
 public static bool DeleteObject(string id)
 {
     Mongo.DeleteObject(x => x.ObjectID == id);
     return(true);
 }
Пример #3
0
 protected static List <T> GetObjects(Expression <Func <T, bool> > condition)
 {
     return(Mongo.RetrieveObjects(condition));
 }
Пример #4
0
 //Multiple
 public static List <T> GetObjects()
 {
     return(Mongo.RetrieveObjects());
 }
Пример #5
0
 //Single
 public static T GetObject(string id)
 {
     return(Mongo.RetrieveObject(x => x.ObjectID == id));
 }
Пример #6
0
 public bool Update()
 {
     Mongo.ReplaceObject(x => x.ObjectID == ObjectID, (T)this);
     return(true);
 }
Пример #7
0
 //Manipulation
 public bool Insert()
 {
     Mongo.InsertObject((T)this);
     return(true);
 }
Пример #8
0
 public MongoProvider(MongoSettings settings)
 {
     Settings = settings;
     mongo    = new MongoDB.Mongo(settings);
 }