コード例 #1
0
        public new Task <TEntity> ExecuteAsync()
        {
            bool withValues = GetTable().GetSession().BinaryProtocolVersion > 1;

            var visitor = new CqlExpressionVisitor();

            visitor.Evaluate(Expression);

            object[] values;
            string   cql = visitor.GetCount(out values, withValues);

            var adaptation =
                InternalExecuteAsync(cql, values).ContinueWith((t) =>
            {
                var rs     = t.Result;
                var result = default(TEntity);
                var row    = rs.FirstOrDefault();
                if (row != null)
                {
                    result = (TEntity)row[0];
                }
                return(result);
            }, TaskContinuationOptions.ExecuteSynchronously);

            return(adaptation);
        }
コード例 #2
0
        public override string CqlString()
        {
            var visitor = new CqlExpressionVisitor();

            visitor.Evaluate(Expression);
            return(visitor.GetCount());
        }
コード例 #3
0
ファイル: CqlUpdate.cs プロジェクト: rasmus-s/csharp-driver
 public override string ToString()
 {
     object[] _;
     var visitor = new CqlExpressionVisitor();
     visitor.Evaluate(Expression);
     return visitor.GetUpdate(out _, _ttl, _timestamp, false);
 }
コード例 #4
0
        protected internal override string GetCql(out object[] values)
        {
            var visitor = new CqlExpressionVisitor(PocoData, Table.Name, Table.KeyspaceName);

            visitor.Evaluate(Expression);
            return(visitor.GetDelete(out values, _timestamp, _ifExists));
        }
コード例 #5
0
        public override IAsyncResult BeginExecute(AsyncCallback callback, object state)
        {
            var visitor = new CqlExpressionVisitor();

            visitor.Evaluate(Expression);
            return(InternalBeginExecute(visitor.GetSelect(), visitor.Mappings, visitor.Alter, callback, state));
        }
コード例 #6
0
        protected override string GetCql(out object[] values)
        {
            var visitor = new CqlExpressionVisitor(PocoData, Table.Name, Table.KeyspaceName);

            visitor.Evaluate(Expression);
            return(visitor.GetSelect(out values));
        }
コード例 #7
0
        public override string GetCql()
        {
            var visitor = new CqlExpressionVisitor();

            visitor.Evaluate(Expression);
            return(visitor.GetUpdate());
        }
コード例 #8
0
        protected override string GetCql()
        {
            var visitor = new CqlExpressionVisitor();

            visitor.Evaluate(Expression);
            return(visitor.GetDelete());
        }
コード例 #9
0
ファイル: CqlUpdate.cs プロジェクト: rasmus-s/csharp-driver
 protected override string GetCql(out object[] values)
 {
     bool withValues = GetTable().GetSession().BinaryProtocolVersion > 1;
     var visitor = new CqlExpressionVisitor();
     visitor.Evaluate(Expression);
     return visitor.GetUpdate(out values, _ttl, _timestamp, withValues);
 }
コード例 #10
0
        protected override string GetCql()
        {
            var visitor = new CqlExpressionVisitor();

            visitor.Evaluate(Expression);
            return(visitor.GetUpdate(_ttl, _timestamp));
        }
コード例 #11
0
        protected override string GetCql(out object[] values)
        {
            var visitor = new CqlExpressionVisitor();

            visitor.Evaluate(Expression);
            return(visitor.GetSelect(out values));
        }
コード例 #12
0
        protected override string CqlString()
        {
            var visitor = new CqlExpressionVisitor();

            visitor.Evaluate(Expression);
            return(visitor.GetSelect());
        }
コード例 #13
0
        /// <summary>
        /// Evaluates the Linq query, executes asynchronously the cql statement and adapts the results.
        /// </summary>
        public Task <IEnumerable <TEntity> > ExecuteAsync()
        {
            bool withValues = GetTable().GetSession().BinaryProtocolVersion > 1;

            var visitor = new CqlExpressionVisitor();

            visitor.Evaluate(Expression);
            object[] values;
            string   cql        = visitor.GetSelect(out values, withValues);
            var      adaptation =
                InternalExecuteAsync(cql, values).ContinueWith((t) =>
            {
                var rs     = t.Result;
                QueryTrace = rs.Info.QueryTrace;

                CqlColumn[] cols = rs.Columns;
                var colToIdx     = new Dictionary <string, int>();
                for (int idx = 0; idx < cols.Length; idx++)
                {
                    colToIdx.Add(cols[idx].Name, idx);
                }
                return(AdaptRows(rs, colToIdx, visitor));
            }, TaskContinuationOptions.ExecuteSynchronously);

            return(adaptation);
        }
コード例 #14
0
ファイル: CqlDelete.cs プロジェクト: rasmus-s/csharp-driver
 public override string ToString()
 {
     var visitor = new CqlExpressionVisitor();
     visitor.Evaluate(Expression);
     object[] _;
     return visitor.GetDelete(out _, _timestamp, _ifExists, false);
 }
コード例 #15
0
        public override string ToString()
        {
            var visitor = new CqlExpressionVisitor();

            visitor.Evaluate(Expression);
            object[] _;
            return(visitor.GetDelete(out _, _timestamp, _ifExists, false));
        }
コード例 #16
0
        protected override string GetCql(out object[] values)
        {
            var withValues = GetTable().GetSession().BinaryProtocolVersion > 1;
            var visitor    = new CqlExpressionVisitor();

            visitor.Evaluate(Expression);
            return(visitor.GetDelete(out values, _timestamp, _ifExists, withValues));
        }
コード例 #17
0
        public override string ToString()
        {
            var visitor = new CqlExpressionVisitor();

            visitor.Evaluate(Expression);
            object[] _;
            return(visitor.GetSelect(out _, false));
        }
コード例 #18
0
        public override string ToString()
        {
            object[] _;
            var      visitor = new CqlExpressionVisitor();

            visitor.Evaluate(Expression);
            return(visitor.GetUpdate(out _, _ttl, _timestamp, false));
        }
コード例 #19
0
        protected override string GetCql(out object[] values)
        {
            bool withValues = GetTable().GetSession().BinaryProtocolVersion > 1;
            var  visitor    = new CqlExpressionVisitor();

            visitor.Evaluate(Expression);
            var type = GetTable().GetEntityType();

            return(visitor.GetUpdate(out values, type, _ttl, _timestamp, withValues));
        }
コード例 #20
0
        /// <summary>
        /// Evaluates the Linq query, executes asynchronously the cql statement and adapts the results.
        /// </summary>
        public Task <IEnumerable <TEntity> > ExecuteAsync()
        {
            var visitor = new CqlExpressionVisitor(PocoData, Table.Name, Table.KeyspaceName);

            visitor.Evaluate(Expression);
            object[] values;
            var      cql = visitor.GetSelect(out values);

            return(InternalExecuteAsync(cql, values).Continue(t => AdaptResult(cql, t.Result)));
        }
コード例 #21
0
        public override IAsyncResult BeginExecute(AsyncCallback callback, object state)
        {
            bool withValues = GetTable().GetSession().BinaryProtocolVersion > 1;
            var  visitor    = new CqlExpressionVisitor();

            visitor.Evaluate(Expression);
            object[] values;
            string   cql = visitor.GetSelect(out values, withValues);

            return(InternalBeginExecute(cql, values, visitor.Mappings, visitor.Alter, callback, state));
        }
コード例 #22
0
        /// <summary>
        /// Evaluates the Linq query, executes asynchronously the cql statement and adapts the results.
        /// </summary>
        public async Task <IEnumerable <TEntity> > ExecuteAsync()
        {
            var visitor = new CqlExpressionVisitor(PocoData, Table.Name, Table.KeyspaceName);

            visitor.Evaluate(Expression);
            object[] values;
            var      cql = visitor.GetSelect(out values);
            var      rs  = await InternalExecuteAsync(cql, values).ConfigureAwait(false);

            return(AdaptResult(cql, rs));
        }
コード例 #23
0
ファイル: CqlQuery.cs プロジェクト: satyajitps/csharp-driver
        /// <summary>
        /// Asynchronously executes the query and returns a task of a page of results
        /// </summary>
        public async Task <IPage <TEntity> > ExecutePagedAsync()
        {
            SetAutoPage(false);
            var visitor = new CqlExpressionVisitor(PocoData, Table.Name, Table.KeyspaceName);

            visitor.Evaluate(Expression);
            object[] values;
            var      cql = visitor.GetSelect(out values);
            var      rs  = await InternalExecuteAsync(cql, values).ConfigureAwait(false);

            var mapper = MapperFactory.GetMapper <TEntity>(cql, rs);

            return(new Page <TEntity>(rs.Select(mapper), PagingState, rs.PagingState));
        }
コード例 #24
0
        /// <summary>
        /// Evaluates the Linq query, executes asynchronously the cql statement and adapts the results.
        /// </summary>
        public Task <IEnumerable <TEntity> > ExecuteAsync()
        {
            var visitor = new CqlExpressionVisitor(PocoData, Table.Name, Table.KeyspaceName);

            visitor.Evaluate(Expression);
            object[] values;
            var      cql        = visitor.GetSelect(out values);
            var      adaptation = InternalExecuteAsync(cql, values).Continue(t =>
            {
                var rs     = t.Result;
                var mapper = MapperFactory.GetMapper <TEntity>(cql, rs);
                return(rs.Select(mapper));
            });

            return(adaptation);
        }
コード例 #25
0
        public void StartsWith_Test()
        {
            var table = new Table<LinqDecoratedWithStringCkEntity>(null);
            var query = table.Where(t => t.pk == "a" && t.ck1.StartsWith("foo") && t.pk == "bar");
            var pocoData = MappingConfiguration.Global.MapperFactory.GetPocoData<LinqDecoratedWithStringCkEntity>();
            var visitor = new CqlExpressionVisitor(pocoData, "x_ts", null);
            visitor.Evaluate(query.Expression);
            object[] parameters;

            var queryCql = visitor.GetSelect(out parameters);

            Assert.That(parameters, Is.EquivalentTo(new[] { "a", "foo", "foo" + Encoding.UTF8.GetString(new byte[] { 0xF4, 0x8F, 0xBF, 0xBF }), "bar" }));
            Assert.AreEqual(@"SELECT ""x_pk"", ""x_ck1"", ""x_f1"" FROM ""x_ts"" WHERE ""x_pk"" = ? AND ""x_ck1"" >= ? AND ""x_ck1"" < ? AND ""x_pk"" = ?", queryCql);
        }
コード例 #26
0
ファイル: CqlUpdate.cs プロジェクト: Virus-X/csharp-driver
 protected internal override string GetCql(out object[] values)
 {
     var visitor = new CqlExpressionVisitor(PocoData, Table.Name, Table.KeyspaceName);
     visitor.Evaluate(Expression);
     return visitor.GetUpdate(out values, _ttl, _timestamp);
 }