public List <string> FindHeaderByMobileNo(string mobileNo) { var mobileNo_ = PhoneNoModule.NormalizePhoneNoFormat(mobileNo); var rows = _store.QueryAsync <string>(new Query("leads", "mobileNo") { Key = mobileNo_ }).Result; var leadDocIds = rows.Select(r => r.Id).ToList(); return(leadDocIds); }
public static async Task <IEnumerable <T> > GetAllAsync <T>(this MyCouchStore db) where T : class { var query = new Query(SystemViewIdentity.AllDocs).Configure(config => config.IncludeDocs(true)); return((await db.QueryAsync <dynamic, T>(query)) .Where(row => !row.Id.StartsWith("_")) .Select(row => row.IncludedDoc as T)); }
public List <Product> GetProductsByBracket(string bracket) { var rows = _store.QueryAsync <Product>(new Query("products", "bracket") { Key = bracket }).Result; var products = rows.Select(r => r.Value).ToList(); return(products); }
/// <summary> /// Temp function, will be removed when datamodel is consistent /// </summary> public async Task<IEnumerable<AllRatingsRow>> GetAllMovieRatings2() { using (var c = new MyCouchStore(_uri)) { var query = new Query("views", "allRatings"); query.Reduce = false; var result = await c.QueryAsync<AllRatingsRow>(query); return result.Select(x => x.Value); } }
public async Task<IEnumerable<MovieInformationRow>> GetAllMovieInformation() { using (var c = new MyCouchStore(_uri)) { var query = new Query("views", "movies"); query.Group = true; var result = await c.QueryAsync<MovieInformationRow>(query); return result.Select(x => x.Value); } }
public IEnumerable<MovieRating> GetAllMovieRatings() { using (var c = new MyCouchStore(_uri)) { var query = new Query("views", "allRatings"); query.Reduce = false; var result = c.QueryAsync<MovieRating>(query).Result; return result.Select(x => x.Value); } }
/// <summary> /// Returns all comments that do not have a parent comment. /// </summary> /// <returns></returns> public IEnumerable <Comment> GetAllRootComments() { var query = new Query("comments", "all_roots"); var result = _commentStore.QueryAsync(query).Result; if (result == null) { yield break; } foreach (var c in result) { if (c.Id != null) { yield return(GetComment(c.Id).Result); } } yield break; }
public void ExportAllDataFromCouchToFiles() { string connectionString = ConfigurationManager.ConnectionStrings["CouchDb"].ConnectionString; using (var c = new MyCouchStore(connectionString)) { var query = new Query("_all_docs") {IncludeDocs = true}; var result = c.QueryAsync(query).Result; var jsonFileParts = new List<string>(); foreach (var obj in result) { var doc = JsonConvert.DeserializeObject<JObject>(obj.IncludedDoc); JToken type; if (doc.TryGetValue("type", out type) && type.ToString() == "MovieRating") jsonFileParts.Add(obj.IncludedDoc); } var json = "[\n" + String.Join(",\n", jsonFileParts) + "\n]"; File.WriteAllText("TestData.json", json); } }