public async Task <IList <TResult> > ToListByFilterAsync <TResult>(Func <IRow, TResult> selector, string fields, Func <IRow, bool> filter, int skip = 0, int take = 0) { builder.Insert(0, fields); builder.Insert(0, "SELECT "); if (Limit > 0) { builder.Append($" LIMIT {Limit}"); } if (AllowFiltering) { builder.Append(" ALLOW FILTERING"); } var cql = StringBuilderCache.GetStringAndRelease(builder); builder = null; var db = CqlStore.Get(model.CqlStoreOptions.StoreModelId); var rs = await db.ExecuteAsync(cql); var list = new List <TResult>(); int hasSkip = 0; int hasTake = 0; foreach (var row in rs) { if (filter(row)) { if (hasSkip < skip) { hasSkip++; } else { list.Add(row.Fetch(selector)); if (take > 0) { hasTake++; if (hasTake == take) { return(list); } } } } } return(list); }
public async Task <IList <TResult> > ToListAsync <TResult>(Func <IRow, TResult> selector, string fields) { builder.Insert(0, fields); builder.Insert(0, "SELECT "); if (Limit > 0) { builder.Append($" LIMIT {Limit}"); } if (AllowFiltering) { builder.Append(" ALLOW FILTERING"); } var cql = StringBuilderCache.GetStringAndRelease(builder); builder = null; var db = CqlStore.Get(model.CqlStoreOptions.StoreModelId); var rs = await db.ExecuteAsync(cql); return(rs.ToList(selector)); }
public async Task <IList <Entity> > ToListAsync() { builder.Insert(0, "SELECT *"); if (Limit > 0) { builder.Append($" LIMIT {Limit}"); } if (AllowFiltering) { builder.Append(" ALLOW FILTERING"); } var cql = StringBuilderCache.GetStringAndRelease(builder); builder = null; var db = CqlStore.Get(model.CqlStoreOptions.StoreModelId); Log.Debug(cql); var rs = await db.ExecuteAsync(cql); return(rs.ToEntityList(model)); }
public CqlBatch(CqlStore store) { this.store = store; Commands = new List <CqlCommand>(); }