public static IView <IViewRow> GetView(CouchbaseClient bucket, string bucketName, string designName, string viewName) { var view = bucket.GetView(viewName, viewName).Stale(global::Couchbase.StaleMode.False).Reduce(false); if (!view.CheckExistsByCache(bucketName, viewName)) { var created = DatabaseHelper.CreateDesignDocument(bucketName, viewName, string.Format(viewTemplate, viewName, ModelExtensions.GetDataType(viewName))); if (created) { DatabaseHelper.ExistedView.Add(DatabaseHelper.GetViewCacheName(bucketName, viewName)); System.Threading.Thread.Sleep(3000); } else { throw new Exception("Create view " + viewName + " faild"); } } return(view); }