Beispiel #1
0
        public void SetUp()
        {
            var host = ConfigurationManager.AppSettings["CouchHost"] ?? "localhost";
            var port = Convert.ToInt32(ConfigurationManager.AppSettings["CouchPort"] ?? "5984");
            server = new CouchServer(host, port);
            DbName = GetNewDbName();
            db = server.GetNewDatabase(DbName);
            Car car = null;

            for (int i = 0; i < 10; i++)
            {
                car = new Car("Saab", "93", 170 + i);
                db.SaveDocument(car);
            }
            tempView = db.NewTempView("test", "test", "if (doc.docType && doc.docType == 'car') emit(doc.Hps, doc);");
        }
Beispiel #2
0
        public long count(string symbol)
        {
            ICouchViewDefinition  tempView  = db.NewTempView("ticks", "ticks", "if (doc.docType && doc.docType == 'tick') emit(doc.symbol, doc);");
            CouchLinqQuery <Tick> linqTicks = tempView.LinqQuery <Tick>();

            var ticks = from t in linqTicks where t.Symbol == symbol select t;
            int count = 0;

            foreach (var t in ticks)
            {
                count++;
            }

            db.DeleteDocument(tempView.Doc);

            return(count);
        }
        /// <summary>
        /// Processes the expression.
        /// </summary>
        /// <param name="expression">The expression.</param>
        /// <param name="db">The db.</param>
        /// <param name="definition">The view definition.</param>
        /// <returns></returns>
        public ExpressionVisitor ProcessExpression(Expression expression, ICouchDatabase db, ICouchViewDefinition definition)
        {
            Query = db.Query(definition);
            VisitExpression(expression);

            switch (keys.Count)
            {
                case 0: // 0 keys means it's a range query. do nothing.
                    break;
                case 1: // 1 key means it's a single Equals or a Contains on a single.
                    Query.Key(keys[0]);
                    break;
                default: // neither 0 nor 1 means that we've got a set of keys to test.
                    Query.Keys(keys);
                    break;
            }

            return this;
        }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CouchQueryProvider"/> class.
 /// </summary>
 /// <param name="db">The db.</param>
 /// <param name="definition">The definition.</param>
 public CouchQueryProvider(ICouchDatabase db, ICouchViewDefinition definition)
 {
     this.db         = db;
     this.definition = definition;
 }
Beispiel #5
0
 public CouchQuery(ICouchViewDefinition view)
 {
     View = view;
 }
Beispiel #6
0
 public CouchQuery Query(ICouchViewDefinition view)
 {
     return(new CouchQuery(view));
 }
Beispiel #7
0
        /// <summary>
        /// Processes the expression.
        /// </summary>
        /// <param name="expression">The expression.</param>
        /// <param name="db">The db.</param>
        /// <param name="definition">The view definition.</param>
        /// <returns></returns>
        public ExpressionVisitor ProcessExpression(Expression expression, ICouchDatabase db, ICouchViewDefinition definition)
        {
            Query = db.Query(definition);
            VisitExpression(expression);

            switch (keys.Count)
            {
            case 0:     // 0 keys means it's a range query. do nothing.
                break;

            case 1:     // 1 key means it's a single Equals or a Contains on a single.
                Query.Key(keys[0]);
                break;

            default:     // neither 0 nor 1 means that we've got a set of keys to test.
                Query.Keys(keys);
                break;
            }

            return(this);
        }