예제 #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);
 }