예제 #1
0
        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);
        }
예제 #2
0
파일: Utils.cs 프로젝트: Kethku/DiscordMud
        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));
        }
예제 #3
0
        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);
        }
예제 #4
0
 /// <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);
     }
 }
예제 #5
0
 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);
     }
 }
예제 #6
0
 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);
     }
 }
예제 #7
0
        /// <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;
        }
예제 #8
0
        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);
            }
        }