コード例 #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);
 }