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); }
public override string CqlString() { var visitor = new CqlExpressionVisitor(); visitor.Evaluate(Expression); return(visitor.GetCount()); }
public override string ToString() { object[] _; var visitor = new CqlExpressionVisitor(); visitor.Evaluate(Expression); return visitor.GetUpdate(out _, _ttl, _timestamp, false); }
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)); }
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)); }
protected override string GetCql(out object[] values) { var visitor = new CqlExpressionVisitor(PocoData, Table.Name, Table.KeyspaceName); visitor.Evaluate(Expression); return(visitor.GetSelect(out values)); }
public override string GetCql() { var visitor = new CqlExpressionVisitor(); visitor.Evaluate(Expression); return(visitor.GetUpdate()); }
protected override string GetCql() { var visitor = new CqlExpressionVisitor(); visitor.Evaluate(Expression); return(visitor.GetDelete()); }
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); }
protected override string GetCql() { var visitor = new CqlExpressionVisitor(); visitor.Evaluate(Expression); return(visitor.GetUpdate(_ttl, _timestamp)); }
protected override string GetCql(out object[] values) { var visitor = new CqlExpressionVisitor(); visitor.Evaluate(Expression); return(visitor.GetSelect(out values)); }
protected override string CqlString() { var visitor = new CqlExpressionVisitor(); visitor.Evaluate(Expression); return(visitor.GetSelect()); }
/// <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); }
public override string ToString() { var visitor = new CqlExpressionVisitor(); visitor.Evaluate(Expression); object[] _; return visitor.GetDelete(out _, _timestamp, _ifExists, false); }
public override string ToString() { var visitor = new CqlExpressionVisitor(); visitor.Evaluate(Expression); object[] _; return(visitor.GetDelete(out _, _timestamp, _ifExists, false)); }
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)); }
public override string ToString() { var visitor = new CqlExpressionVisitor(); visitor.Evaluate(Expression); object[] _; return(visitor.GetSelect(out _, false)); }
public override string ToString() { object[] _; var visitor = new CqlExpressionVisitor(); visitor.Evaluate(Expression); return(visitor.GetUpdate(out _, _ttl, _timestamp, false)); }
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)); }
/// <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))); }
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)); }
/// <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)); }
/// <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)); }
/// <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); }
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); }
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); }