public async Task <List <Row> > ExecuteQuery(dynamic parameters, PreparedStatement statement = null) { if (string.IsNullOrEmpty(this.query) && statement == null) { throw new ArgumentNullException("Query is not set. Use the Prepare Query method to set the query first"); } if (this.currentSession == null) { createConnection(); } try { if (statement == null) { statement = currentSession.Prepare(this.query); } var boundStatement = statement.Bind(parameters); RowSet result = currentSession.Execute(boundStatement); return(result.AsEnumerable().ToList()); } catch (Exception exception) { CoreContainers.LogsRepository.LogError(exception, Core.Database.Logs.LogTrigger.DataAccess); return(new List <Row>()); } }
public IEnumerable <string> Get() { IDseCluster cluster = DseCluster.Builder() .AddContactPoint("127.0.0.1") .Build(); IDseSession session = cluster.Connect(); var get_users = session.Prepare("SELECT * FROM driver_test.user"); RowSet results = session.Execute(get_users.Bind()); List <string> final_results = new List <string>(); foreach (Row row in results.AsEnumerable()) { final_results.Add(row.GetValue <Guid>("id").ToString() + " " + row.GetValue <String>("first_name") + " " + row.GetValue <String>("last_name") + "\n"); } return(final_results); }