{"id":13087,"date":"2022-04-18T11:02:34","date_gmt":"2022-04-18T18:02:34","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=13087"},"modified":"2025-06-13T20:56:46","modified_gmt":"2025-06-14T03:56:46","slug":"asp-net-crud-nosql-part-2","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/es\/asp-net-crud-nosql-part-2\/","title":{"rendered":"ASP.NET Core CRUD con NoSQL: Parte 2"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">CRUD significa Crear, Leer, Actualizar y Eliminar. En la parte 2, veremos R para Read, y construiremos un endpoint ASP.NET Core para leer datos de Couchbase usando SQL.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Aseg\u00farese de leer <\/span><a href=\"https:\/\/www.couchbase.com\/blog\/es\/asp-net-core-crud-with-nosql-part-1\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">parte 1 de esta serie<\/span><\/a><span style=\"font-weight: 400;\">que cubre la instalaci\u00f3n y configuraci\u00f3n de su proyecto ASP.NET Core \"wishlist\".<\/span><\/p>\n<h2><b>SQL++ para leer<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Couchbase es \u00fanica entre las bases de datos NoSQL en el sentido de que admite un <\/span><a href=\"https:\/\/cloud.couchbase.com\/sign-up\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">implementaci\u00f3n completa de SQL<\/span><\/a><span style=\"font-weight: 400;\"> (llamado SQL++, de soltera N1QL) para consultar datos JSON.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">SQL++ no es un lenguaje \"tipo SQL\" diluido. Con SQL++, dispone de <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/join.html\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Se une a<\/span><\/a><span style=\"font-weight: 400;\">, <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/with.html\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">CTEs\/WITH<\/span><\/a><span style=\"font-weight: 400;\">, <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/update.html\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">ACTUALIZACI\u00d3N<\/span><\/a><span style=\"font-weight: 400;\">, <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/insert.html\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">INSERTAR<\/span><\/a><span style=\"font-weight: 400;\">, <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/delete.html\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">BORRAR<\/span><\/a><span style=\"font-weight: 400;\">, <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/merge.html\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">FUSIONAR<\/span><\/a><span style=\"font-weight: 400;\">, <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/groupby.html\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">agregaci\u00f3n\/GROUP BY<\/span><\/a><span style=\"font-weight: 400;\">, <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/begin-transaction.html\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">INICIO\/COMPROMISO\/RETROCESO<\/span><\/a><span style=\"font-weight: 400;\">y mucho m\u00e1s.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Adem\u00e1s (el \"++\"), tambi\u00e9n dispone de funciones para tratar datos JSON, como <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/datatypes.html#datatype-missing\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">FALTA<\/span><\/a><span style=\"font-weight: 400;\">, <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/nest.html\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">NEST<\/span><\/a><span style=\"font-weight: 400;\">, <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/arrayfun.html\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Funciones ARRAY_*<\/span><\/a><span style=\"font-weight: 400;\">, <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/objectfun.html\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Funciones OBJECT_*<\/span><\/a><span style=\"font-weight: 400;\">y mucho m\u00e1s.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Para esta sencilla aplicaci\u00f3n CRUD, utilizaremos un SQL++ <\/span><span style=\"font-weight: 400;\">SELECCIONE<\/span><span style=\"font-weight: 400;\"> consulta (e \u00edndice) para devolver <\/span><b>todos<\/b><span style=\"font-weight: 400;\"> art\u00edculos de mi lista de deseos.<\/span><\/p>\n<h2><b>Escribir su primera consulta SQL<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">En primer lugar, vamos a intentar escribir una consulta SQL++ para obtener todos los elementos de la lista de deseos en la carpeta <\/span><a href=\"https:\/\/docs.couchbase.com\/cloud\/clusters\/query-service\/query-workbench.html\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Workbench de consulta Capella<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Para empezar, int\u00e9ntalo:<\/span><\/p>\n<pre class=\"decode-attributes:false lang:tsql decode:true\">SELECT * FROM demo._default.wishlist;<\/pre>\n<p><span style=\"font-weight: 400;\">Al hacerlo, deber\u00eda aparecer un mensaje de error. Algo como:<\/span><\/p>\n<pre class=\"decode-attributes:false lang:default decode:true\">`no index available on keyspace default:demo._default.wishlist that matches your query. Use CREATE PRIMARY INDEX` ...<\/pre>\n<p><span style=\"font-weight: 400;\">Este es el comportamiento esperado. (La mayor\u00eda) de las consultas SQL++ en Couchbase no se ejecutar\u00e1n a menos que haya al menos un \u00edndice disponible para ellas.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">No hay problema. Cree un sencillo <\/span><a href=\"https:\/\/docs.couchbase.com\/server\/current\/n1ql\/n1ql-language-reference\/createprimaryindex.html\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">\u00cdNDICE PRIMARIO<\/span><\/a><span style=\"font-weight: 400;\"> con un comando como este:<\/span><\/p>\n<pre class=\"decode-attributes:false lang:tsql decode:true\">CREATE PRIMARY INDEX `ix_wishlist` ON `demo`.`_default`.`wishlist`<\/pre>\n<p><span style=\"font-weight: 400;\">Por lo general, los \u00edndices primarios no est\u00e1n pensados para ser utilizados en un entorno de producci\u00f3n t\u00edpico, pero son muy \u00fatiles para un entorno de desarrollo, ya que garantizan que <\/span><b>cualquier<\/b><span style=\"font-weight: 400;\"> La consulta SQL++ se ejecutar\u00e1 en la colecci\u00f3n indexada (aunque no ser\u00e1 tan eficiente como una colecci\u00f3n indexada correctamente). Una vez que empiece a crear consultas SQL++ m\u00e1s complejas, puede utilizar la funci\u00f3n <\/span><a href=\"https:\/\/docs.couchbase.com\/cloud\/clusters\/query-service\/query-workbench.html#index-advisor\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Bot\u00f3n \"Aconsejar\" en el Query Workbench<\/span><\/a><span style=\"font-weight: 400;\"> para obtener sugerencias de \u00edndices m\u00e1s eficientes para crear (y usted debe evitar el uso de <\/span><span style=\"font-weight: 400;\">SELECCIONAR *<\/span><span style=\"font-weight: 400;\"> siempre que puedas \ud83d\ude06).<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Despu\u00e9s de crear el \u00edndice, vuelva a intentar lo anterior <\/span><span style=\"font-weight: 400;\">SELECCIONE<\/span><span style=\"font-weight: 400;\"> y los resultados ser\u00e1n los siguientes:<\/span><\/p>\n<pre class=\"decode-attributes:false lang:tsql decode:true\">[\r\n\u00a0 {\r\n\u00a0 \u00a0 \"wishlist\": {\r\n\u00a0 \u00a0 \u00a0 \"name\": \"Skyline Chili T-Shirt\"\r\n\u00a0 \u00a0 }\r\n\u00a0 },\r\n\u00a0 {\r\n\u00a0 \u00a0 \"wishlist\": {\r\n\u00a0 \u00a0 \u00a0 \"name\": \"Joey Votto jersey\"\r\n\u00a0 \u00a0 }\r\n\u00a0 }\r\n]<\/pre>\n<p><span style=\"font-weight: 400;\">Ya casi est\u00e1. Trate de imaginar esta matriz de objetos que se serializa a un C# <\/span><em><span style=\"font-weight: 400;\">Lista<\/span><\/em><span style=\"font-weight: 400;\">. No funcionar\u00eda del todo, porque los objetos est\u00e1n anidados con el nombre de la colecci\u00f3n. As\u00ed que me he acostumbrado a poner alias a las colecciones, as\u00ed:<\/span><\/p>\n<pre class=\"decode-attributes:false lang:tsql decode:true\">SELECT w.* FROM demo._default.wishlist w;<\/pre>\n<p><span style=\"font-weight: 400;\">Lo que produce el resultado:<\/span><\/p>\n<pre class=\"decode-attributes:false lang:js decode:true\">[\r\n\u00a0 {\r\n\u00a0 \u00a0 \"name\": \"Skyline Chili T-Shirt\"\r\n\u00a0 },\r\n\u00a0 {\r\n\u00a0 \u00a0 \"name\": \"Joey Votto jersey\"\r\n\u00a0 }\r\n]<\/pre>\n<p><span style=\"font-weight: 400;\">Se ve bien, pero todav\u00eda falta algo. \u00bfD\u00f3nde est\u00e1n esos GUIDs que usamos para las claves de los documentos? Couchbase no los almacena como datos; los almacena como <\/span><b>metadatos<\/b><span style=\"font-weight: 400;\">. SQL++ proporciona la <\/span><em><span style=\"font-weight: 400;\">META()<\/span><\/em><span style=\"font-weight: 400;\"> para consultar metadatos. Utilice <\/span><em><span style=\"font-weight: 400;\">META().id<\/span><\/em><span style=\"font-weight: 400;\"> as\u00ed:<\/span><\/p>\n<pre class=\"decode-attributes:false lang:tsql decode:true\">SELECT META(w).id, w.* FROM demo._default.wishlist w;<\/pre>\n<p><span style=\"font-weight: 400;\">Y que finalmente nos da un resultado de:<\/span><\/p>\n<pre class=\"decode-attributes:false lang:js decode:true\">[\r\n\u00a0 {\r\n\u00a0 \u00a0 \"id\": \"2dab198b-1836-4409-9bdf-17275a2b2462\",\r\n\u00a0 \u00a0 \"name\": \"Skyline Chili T-Shirt\"\r\n\u00a0 },\r\n\u00a0 {\r\n\u00a0 \u00a0 \"id\": \"31c9cc33-8dfe-440c-bd1b-bb038939d2e0\",\r\n\u00a0 \u00a0 \"name\": \"Joey Votto jersey\"\r\n\u00a0 }\r\n]<\/pre>\n<p><span style=\"font-weight: 400;\">Esto se serializar\u00e1 muy bien en <\/span><em><span style=\"font-weight: 400;\">WishlistItem<\/span><\/em><span style=\"font-weight: 400;\"> utilizando la clase creada en la parte 1.<\/span><\/p>\n<h2><b>Uso de SQL++ en ASP.NET Core<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Pongamos esa consulta SQL++ que acabamos de escribir en un endpoint ASP.NET Core.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">En <em>GiftsController<\/em>cree un endpoint llamado <em>GetAll<\/em>:<\/span><\/p>\n<pre class=\"decode-attributes:false lang:c# decode:true\">[HttpGet]\r\n[Route(\"api\/getall\")]\r\npublic async Task&lt;IActionResult&gt; GetAll()\r\n{\r\n\r\n}<\/pre>\n<p><span style=\"font-weight: 400;\">Para ejecutar SQL++, necesitamos obtener un objeto de tipo <\/span><span style=\"font-weight: 400;\">Grupo<\/span><span style=\"font-weight: 400;\">. SQL++ se ejecuta a nivel de cluster (no de bucket, ni de scope, ni de colecci\u00f3n, ya que puede necesitar <\/span><span style=\"font-weight: 400;\">\u00daNASE A<\/span><span style=\"font-weight: 400;\">\/<\/span><span style=\"font-weight: 400;\">UNI\u00d3N<\/span><span style=\"font-weight: 400;\"> entre ellos). Podr\u00edamos volver atr\u00e1s y a\u00f1adir <\/span><a href=\"https:\/\/docs.couchbase.com\/dotnet-sdk\/current\/howtos\/managing-connections.html#injecting-the-couchbase-cluster\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">ClusterProvider<\/span><\/a><span style=\"font-weight: 400;\"> como par\u00e1metro del constructor. Si este endpoint fuera a funcionar s\u00f3lo con SQL++, ser\u00eda una buena idea. Sin embargo, sigamos con lo que creamos en la parte 1. Tenemos un objeto de tipo <\/span><em><span style=\"font-weight: 400;\">BucketProvider<\/span><\/em><span style=\"font-weight: 400;\">. A partir de ese objeto, se puede obtener un objeto de tipo <\/span><span style=\"font-weight: 400;\">Grupo<\/span><span style=\"font-weight: 400;\">:<\/span><\/p>\n<pre class=\"decode-attributes:false lang:c# decode:true\">[HttpGet]\r\n[Route(\"api\/getall\")]\r\npublic async Task&lt;IActionResult&gt; GetAll()\r\n{\r\n  var bucket = await _bucketProvider.GetBucketAsync(\"demo\");\r\n  var cluster = bucket.Cluster;\r\n\r\n  \/\/ ... snip ...\r\n}<\/pre>\n<p><span style=\"font-weight: 400;\">A <\/span><span style=\"font-weight: 400;\">grupo<\/span><span style=\"font-weight: 400;\"> es la forma en que ASP.NET Core interactuar\u00e1 con un cl\u00faster Couchbase de diversas maneras. Por ahora, estamos interesados en su <\/span><em><span style=\"font-weight: 400;\">QueryAsync<\/span><\/em><span style=\"font-weight: 400;\"> m\u00e9todo:<\/span><\/p>\n<pre class=\"decode-attributes:false lang:c# decode:true\">[HttpGet]\r\n[Route(\"api\/getall\")]\r\npublic async Task&lt;IActionResult&gt; GetAll()\r\n{\r\n  var bucket = await _bucketProvider.GetBucketAsync(\"demo\");\r\n  var cluster = bucket.Cluster;\r\n\r\n  var result = await cluster.QueryAsync&lt;WishlistItem&gt;(\r\n    \"SELECT META(w).id, w.* FROM demo._default.wishlist w;\"\r\n  );\r\n\r\n  return Ok(result);\r\n}<\/pre>\n<p><span style=\"font-weight: 400;\">Aseg\u00farese de que dispone de lo siguiente <\/span><span style=\"font-weight: 400;\">utilizando<\/span><span style=\"font-weight: 400;\"> en la parte superior de su <em>GiftsController.cs<\/em> file:<\/span><\/p>\n<pre class=\"decode-attributes:false lang:c# decode:true\">using AspNetCoreTutorial.Models;\r\nusing Microsoft.AspNetCore.Mvc;\r\nusing Couchbase;\r\nusing Couchbase.Query;\r\nusing Couchbase.Extensions.DependencyInjection;<\/pre>\n<p><span style=\"font-weight: 400;\">Una cosa m\u00e1s a tener en cuenta. Cuando se ejecuta SQL++, hay una serie de <\/span><a href=\"https:\/\/docs.couchbase.com\/dotnet-sdk\/current\/howtos\/n1ql-queries-with-sdk.html#scan-consistency\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">opciones de coherencia (escaneado)<\/span><\/a><span style=\"font-weight: 400;\">. El valor por defecto es <\/span><em><span style=\"font-weight: 400;\">ConsistenciaEscaneo.NotBounded<\/span><\/em><span style=\"font-weight: 400;\">. Esta configuraci\u00f3n significa que el motor de consulta <\/span><b>no<\/b><span style=\"font-weight: 400;\"> esperar a que los \u00edndices terminen de actualizarse antes de devolver los resultados. Esta es la opci\u00f3n m\u00e1s eficaz. Sin embargo, en algunas situaciones, querr\u00e1s una mayor consistencia en los \u00edndices. Couchbase proporciona <\/span><em><span style=\"font-weight: 400;\">SolicitarPlus<\/span><\/em><span style=\"font-weight: 400;\"> y <\/span><em><span style=\"font-weight: 400;\">AtPlus<\/span><\/em><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h2><b>Pruebe el punto final de ASP.NET Core<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">Desde Visual Studio, <strong>Ctrl+F5<\/strong> iniciar\u00e1 la aplicaci\u00f3n. Deber\u00edas ver una p\u00e1gina OpenAPI \/ Swagger en tu navegador.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13088\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2022\/04\/image1-1.png\" alt=\"ASP.NET app reading from Couchbase\" width=\"827\" height=\"452\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/image1-1.png 827w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/image1-1-300x164.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/image1-1-768x420.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/image1-1-20x11.png 20w\" sizes=\"auto, (max-width: 827px) 100vw, 827px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">(Ignorar <em>Previsi\u00f3n meteorol\u00f3gica<\/em>que viene con la plantilla de Visual Studio).<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Haga clic en el punto final para probarlo. No hay par\u00e1metros que especificar, as\u00ed que simplemente haga clic en <strong>Ejecute<\/strong>.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13089\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2022\/04\/image2-1.png\" alt=\"Testing an ASP.NET endpoint and Couchbase\" width=\"806\" height=\"809\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/image2-1.png 806w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/image2-1-300x301.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/image2-1-150x150.png 150w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/image2-1-768x771.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/image2-1-65x65.png 65w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/image2-1-50x50.png 50w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/image2-1-20x20.png 20w\" sizes=\"auto, (max-width: 806px) 100vw, 806px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">Ahora tiene la \"R\" de CRUD en su lugar.<\/span><\/p>\n<h2><b>\u00bfY ahora qu\u00e9?<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">El proyecto ASP.NET Core est\u00e1 conectado a Couchbase Capella, y est\u00e1 leyendo datos a trav\u00e9s de SQL++.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">En la pr\u00f3xima entrada del blog, crearemos otro punto final de \"lectura\". En lugar de SQL++, veremos otra forma m\u00e1s r\u00e1pida de acceder a los datos y leerlos.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Mientras tanto, deber\u00edas:<\/span><\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/cloud.couchbase.com\/sign-up\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Prueba gratuita de Capella<\/span><\/a><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Echa un vistazo a la <\/span><a href=\"https:\/\/cloud.couchbase.com\/sign-up\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Couchbase Playground para .NET<\/span><\/a><span style=\"font-weight: 400;\"> que puede ejecutar directamente en el navegador.<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>CRUD stands for Create, Read, Update, and Delete. In part 2, we\u2019ll look at R for Read, and build an ASP.NET Core endpoint to read data from Couchbase using SQL. Make sure to read part 1 of this series, which [&hellip;]<\/p>","protected":false},"author":71,"featured_media":13090,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1811,10126,10127,1816],"tags":[],"ppma_author":[8937],"class_list":["post-13087","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet","category-asp-dotnet","category-c-sharp","category-couchbase-server"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.8 (Yoast SEO v25.8) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>ASP.NET Core CRUD with NoSQL: Part 2 - The Couchbase Blog<\/title>\n<meta name=\"description\" content=\"In this post we look at the R in CRUD that stands for Read, and we build an ASP.NET Core endpoint to read data from Couchbase using SQL.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/es\/asp-net-crud-nosql-part-2\/\" \/>\n<meta property=\"og:locale\" content=\"es_MX\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ASP.NET Core CRUD with NoSQL: Part 2\" \/>\n<meta property=\"og:description\" content=\"In this post we look at the R in CRUD that stands for Read, and we build an ASP.NET Core endpoint to read data from Couchbase using SQL.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/es\/asp-net-crud-nosql-part-2\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2022-04-18T18:02:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T03:56:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/asp-net-couchbase-read-app-part2-scaled.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1707\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Matthew Groves\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@mgroves\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Matthew Groves\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/\"},\"author\":{\"name\":\"Matthew Groves\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/3929663e372020321b0152dc4fa65a58\"},\"headline\":\"ASP.NET Core CRUD with NoSQL: Part 2\",\"datePublished\":\"2022-04-18T18:02:34+00:00\",\"dateModified\":\"2025-06-14T03:56:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/\"},\"wordCount\":801,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/asp-net-couchbase-read-app-part2-scaled.jpg\",\"articleSection\":[\".NET\",\"ASP.NET\",\"C#\",\"Couchbase Server\"],\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/\",\"name\":\"ASP.NET Core CRUD with NoSQL: Part 2 - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/asp-net-couchbase-read-app-part2-scaled.jpg\",\"datePublished\":\"2022-04-18T18:02:34+00:00\",\"dateModified\":\"2025-06-14T03:56:46+00:00\",\"description\":\"In this post we look at the R in CRUD that stands for Read, and we build an ASP.NET Core endpoint to read data from Couchbase using SQL.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/asp-net-couchbase-read-app-part2-scaled.jpg\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/asp-net-couchbase-read-app-part2-scaled.jpg\",\"width\":2560,\"height\":1707,\"caption\":\"ASP.NET app tutorial to read from Couchbase NoSQL\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"ASP.NET Core CRUD with NoSQL: Part 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"es\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/3929663e372020321b0152dc4fa65a58\",\"name\":\"Matthew Groves\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/ba51e6aacc53995c323a634e4502ef54\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/70feb1b28a099ad0112b8d21fe1e81e1a4524beed3e20b7f107d5370e85a07ab?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/70feb1b28a099ad0112b8d21fe1e81e1a4524beed3e20b7f107d5370e85a07ab?s=96&d=mm&r=g\",\"caption\":\"Matthew Groves\"},\"description\":\"Matthew D. Groves is a guy who loves to code. It doesn't matter if it's C#, jQuery, or PHP: he'll submit pull requests for anything. He has been coding professionally ever since he wrote a QuickBASIC point-of-sale app for his parent's pizza shop back in the 90s. He currently works as a Senior Product Marketing Manager for Couchbase. His free time is spent with his family, watching the Reds, and getting involved in the developer community. He is the author of AOP in .NET, Pro Microservices in .NET, a Pluralsight author, and a Microsoft MVP.\",\"sameAs\":[\"https:\/\/crosscuttingconcerns.com\",\"https:\/\/x.com\/mgroves\"],\"url\":\"https:\/\/www.couchbase.com\/blog\/es\/author\/matthew-groves\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"ASP.NET Core CRUD with NoSQL: Part 2 - The Couchbase Blog","description":"In this post we look at the R in CRUD that stands for Read, and we build an ASP.NET Core endpoint to read data from Couchbase using SQL.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/es\/asp-net-crud-nosql-part-2\/","og_locale":"es_MX","og_type":"article","og_title":"ASP.NET Core CRUD with NoSQL: Part 2","og_description":"In this post we look at the R in CRUD that stands for Read, and we build an ASP.NET Core endpoint to read data from Couchbase using SQL.","og_url":"https:\/\/www.couchbase.com\/blog\/es\/asp-net-crud-nosql-part-2\/","og_site_name":"The Couchbase Blog","article_published_time":"2022-04-18T18:02:34+00:00","article_modified_time":"2025-06-14T03:56:46+00:00","og_image":[{"width":2560,"height":1707,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/asp-net-couchbase-read-app-part2-scaled.jpg","type":"image\/jpeg"}],"author":"Matthew Groves","twitter_card":"summary_large_image","twitter_creator":"@mgroves","twitter_misc":{"Written by":"Matthew Groves","Est. reading time":"4 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/"},"author":{"name":"Matthew Groves","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/3929663e372020321b0152dc4fa65a58"},"headline":"ASP.NET Core CRUD with NoSQL: Part 2","datePublished":"2022-04-18T18:02:34+00:00","dateModified":"2025-06-14T03:56:46+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/"},"wordCount":801,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/asp-net-couchbase-read-app-part2-scaled.jpg","articleSection":[".NET","ASP.NET","C#","Couchbase Server"],"inLanguage":"es","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/","url":"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/","name":"ASP.NET Core CRUD with NoSQL: Part 2 - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/asp-net-couchbase-read-app-part2-scaled.jpg","datePublished":"2022-04-18T18:02:34+00:00","dateModified":"2025-06-14T03:56:46+00:00","description":"In this post we look at the R in CRUD that stands for Read, and we build an ASP.NET Core endpoint to read data from Couchbase using SQL.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/"]}]},{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/asp-net-couchbase-read-app-part2-scaled.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/04\/asp-net-couchbase-read-app-part2-scaled.jpg","width":2560,"height":1707,"caption":"ASP.NET app tutorial to read from Couchbase NoSQL"},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/asp-net-crud-nosql-part-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"ASP.NET Core CRUD with NoSQL: Part 2"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"El blog de Couchbase","description":"Couchbase, la base de datos NoSQL","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"es"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"El blog de Couchbase","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/3929663e372020321b0152dc4fa65a58","name":"Matthew Groves","image":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/ba51e6aacc53995c323a634e4502ef54","url":"https:\/\/secure.gravatar.com\/avatar\/70feb1b28a099ad0112b8d21fe1e81e1a4524beed3e20b7f107d5370e85a07ab?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/70feb1b28a099ad0112b8d21fe1e81e1a4524beed3e20b7f107d5370e85a07ab?s=96&d=mm&r=g","caption":"Matthew Groves"},"description":"A Matthew D. Groves le encanta programar. No importa si se trata de C#, jQuery o PHP: enviar\u00e1 pull requests para cualquier cosa. Lleva codificando profesionalmente desde que escribi\u00f3 una aplicaci\u00f3n de punto de venta en QuickBASIC para la pizzer\u00eda de sus padres, all\u00e1 por los a\u00f1os noventa. Actualmente trabaja como Director de Marketing de Producto para Couchbase. Su tiempo libre lo pasa con su familia, viendo a los Reds y participando en la comunidad de desarrolladores. Es autor de AOP in .NET, Pro Microservices in .NET, autor de Pluralsight y MVP de Microsoft.","sameAs":["https:\/\/crosscuttingconcerns.com","https:\/\/x.com\/mgroves"],"url":"https:\/\/www.couchbase.com\/blog\/es\/author\/matthew-groves\/"}]}},"authors":[{"term_id":8937,"user_id":71,"is_guest":0,"slug":"matthew-groves","display_name":"Matthew Groves","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/70feb1b28a099ad0112b8d21fe1e81e1a4524beed3e20b7f107d5370e85a07ab?s=96&d=mm&r=g","author_category":"","last_name":"Groves","first_name":"Matthew","job_title":"","user_url":"https:\/\/crosscuttingconcerns.com","description":"A Matthew D. Groves le encanta programar.  No importa si se trata de C#, jQuery o PHP: enviar\u00e1 pull requests para cualquier cosa.  Lleva codificando profesionalmente desde que escribi\u00f3 una aplicaci\u00f3n de punto de venta en QuickBASIC para la pizzer\u00eda de sus padres, all\u00e1 por los a\u00f1os noventa.  Actualmente trabaja como Director de Marketing de Producto para Couchbase. Su tiempo libre lo pasa con su familia, viendo a los Reds y participando en la comunidad de desarrolladores.  Es autor de AOP in .NET, Pro Microservices in .NET, autor de Pluralsight y MVP de Microsoft."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/posts\/13087","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/users\/71"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/comments?post=13087"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/posts\/13087\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/media\/13090"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/media?parent=13087"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/categories?post=13087"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/tags?post=13087"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/es\/wp-json\/wp\/v2\/ppma_author?post=13087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}