Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="repository"></param>
        /// <param name="queryText">The query text is the name of view. Composite of "DesignName/ViewName" </param>
        /// <param name="commandType"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public IEnumerable <IDictionary <string, object> > ExecuteQuery(Models.Repository repository, string queryText, System.Data.CommandType commandType = System.Data.CommandType.Text, params KeyValuePair <string, object>[] parameters)
        {
            if (string.IsNullOrEmpty(queryText))
            {
                throw new Exception("Parameter:queryText is Null Or Empty.");
            }

            string[] paras = queryText.Split('/');
            if (paras.Length != 2)
            {
                throw new Exception("Parameter:queryText format is error.");
            }

            var client = repository.GetClient();
            var view   = client.GetView(paras[0], paras[1]);

            List <Dictionary <string, object> > ret = new List <Dictionary <string, object> >();

            foreach (var row in view)
            {
                var dict = row.Info["value"] as Dictionary <string, object>;
                ret.Add(dict);
            }
            return(ret);
        }
Example #2
0
        public void ImportCategoryData(Models.Repository repository, IEnumerable <Models.Category> data)
        {
            var bucket = repository.GetClient();

            ////导入站点不用PersistTo
            data.ForEach((it, index) =>
            {
                bucket.Store(StoreMode.Set, it.GetDocumentKey(), it.ToJson());
            });
        }