Example #1
0
            /// <summary>
            /// Gets the join result
            /// </summary>
            /// <returns> A string with the query result </returns>
            public string Find(IMongoQuery query = null)
            {
                var myQuery = "{}";

                if (query != null)
                {
                    myQuery = query.ToJson();
                }

                string         queryFunction = "generalSearch ( \"" + this.collection + "\"" + ", " + myQuery + ", " + JsonConvert.SerializeObject(this.joins) + " )";
                BsonJavaScript JoinFunction  = new BsonJavaScript(queryFunction);

                //Calling the stores Mongo Function
                MongoConection      conection = (MongoConection)Conection.getConection();
                BsonArray           result    = conection.getDataBase().Eval(JoinFunction).AsBsonArray;
                List <BsonDocument> documents = new List <BsonDocument>();

                foreach (BsonDocument document in result)
                {
                    document.Set("_id", document.GetElement("_id").Value.ToString());
                    try
                    {
                        document.Set("CreatedTimeStamp", document.GetElement("CreatedTimeStamp").Value.ToString());
                    }
                    catch (Exception ex) { }

                    documents.Add(document);
                }

                return(documents.ToJson());
            }
Example #2
0
        public string GetIdUnico()
        {
            string         queryFunction = "getIDOne()";
            BsonJavaScript SubFunction   = new BsonJavaScript(queryFunction);

            //Calling the stores Mongo Function
            MongoConection conection = (MongoConection)Conection.getConection();
            double         result    = conection.getDataBase().Eval(SubFunction).AsDouble;

            return(result.ToString());
        }
Example #3
0
 public MongoModel(String name, Dictionary <string, string> dbConf = null, Boolean authAgainstAdmin = false)
 {
     conection  = (MongoConection)Conection.getConection(dbConf);
     collection = conection.getCollection(name, authAgainstAdmin);
 }