{"id":21326320,"url":"https://github.com/programando-ideas/webapi_odata_ef","last_synced_at":"2025-03-15T23:44:43.797Z","repository":{"id":40863369,"uuid":"266408592","full_name":"programando-ideas/webapi_odata_ef","owner":"programando-ideas","description":"OData + ASPNET Core WebApi 3.1 + Entity Framework Core","archived":false,"fork":false,"pushed_at":"2022-12-08T11:20:39.000Z","size":65,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T12:32:46.968Z","etag":null,"topics":["csharp","entity-framework","odata","odata-aspnet","video"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/programando-ideas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-23T19:50:03.000Z","updated_at":"2020-09-14T16:09:04.000Z","dependencies_parsed_at":"2023-01-25T12:30:10.365Z","dependency_job_id":null,"html_url":"https://github.com/programando-ideas/webapi_odata_ef","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programando-ideas%2Fwebapi_odata_ef","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programando-ideas%2Fwebapi_odata_ef/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programando-ideas%2Fwebapi_odata_ef/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programando-ideas%2Fwebapi_odata_ef/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/programando-ideas","download_url":"https://codeload.github.com/programando-ideas/webapi_odata_ef/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243806041,"owners_count":20350775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","entity-framework","odata","odata-aspnet","video"],"created_at":"2024-11-21T21:09:13.679Z","updated_at":"2025-03-15T23:44:43.766Z","avatar_url":"https://github.com/programando-ideas.png","language":"C#","readme":"# OData + ASPNET Core WebApi 3.1 + Entity Framework Core\n**OData** aplicado a **ASP.NET Core WebApi 3.1** utilizando **Entity Framework Core**. 📇 📋 📂\n\n## Video Youtube\n[📚 𝖮𝖣𝖺𝗍𝖺 + 𝖤𝗇𝗍𝗂𝗍𝗒 𝖥𝗋𝖺𝗆𝖾𝗐𝗈𝗋𝗄 + 𝖠𝖲𝖯.𝖭𝖤𝖳 𝖢𝗈𝗋𝖾 𝖶𝖾𝖻𝖠𝗉𝗂 𝟥.𝟣 📝🔎](https://youtu.be/xsCiXMzAVQ8)\n\n## Herramientas necesarias ejecutar y probar este proyecto\n- [x] SQL Server Developer Edition\n- [x] SQL Server Management Studio\n- [x] Visual Studio 2019 Community\n- [x] .net Core 3.1\n- [x] PostMan\n\n## Referencias de importancia\n - Extension para Visual Studio\n    - https://marketplace.visualstudio.com/items?itemName=unchase.UnchaseODataConnectedService\n    - https://devblogs.microsoft.com/odata/tutorial-sample-how-to-use-odata-client-code-generator-to-generate-client-side-proxy-class/\n - Cliente OData con HttpClient: https://docs.microsoft.com/es-es/odata/client/using-httpclient\n \n## Configuraciones del proyecto\n### ClienteOData\nCliente de ejemplo utilizando HttpClient\n### ServerOData\nWebApi con OData\n\n#### Agregar al archivo del proyecto webapi_odata_ef.csproj\n```xml\n\u003cGenerateRuntimeConfigurationFiles\u003eTrue\u003c/GenerateRuntimeConfigurationFiles\u003e\n```\n#### Paquetes de Nuget\n- [x] Microsoft.AspNetCore.OData\n- [x] Microsoft.EntityFrameworkCore\n- [x] Microsoft.EntityFrameworkCore.SqlServer\n- [x] Microsoft.EntityFrameworkCore.Design\n- [x] Microsoft.VisualStudio.Web.CodeGeneration.Design\n\n## Entity Framework Core (code-first)\n\n```bash\n# Para instalar la herramienta dotnet-ef\ndotnet tool install --global dotnet-ef\n\n# Para generar la base de datos\ndotnet-ef migrations add Initial\ndotnet-ef database update\n```\n\n## Consultas para realizar con OData\n#### GET\n- http://localhost:5000/odata/personas?$select=NombreYApellido\n- http://localhost:5000/odata/personas?$filter=Id eq 1\n- http://localhost:5000/odata/personas?$expand=Telefono,Direccion\n- http://localhost:5000/odata/personas?$expand=telefono,direccion\u0026$filter=Id eq 1\n- http://localhost:5000/api/personasapi?$expand=telefono,direccion\u0026$filter=Id eq 2\n\n#### POST\n- http://localhost:5000/odata/personas%281%29/CrearPersona\n```json\n{\n  \"NombreYApellido\": \"Luciano\",\n  \"Edad\": 23,\n  \"Telefonos\": [\n  {\n    \"TelefonoDesc\": \"+528885555444\"\n  },\n  {\n    \"TelefonoDesc\": \"+551234567890\"\n  }],\n  \"Direcciones\": [\n  {\n    \"DireccionDesc\": \"Calle 23\"\n  }]\n}\n```\n- http://localhost:5000/odata/Personas\n```markdown\nNombreYApellido: Nueva Persona\nEdad: 23\nTelefono[0].TelefonoDesc: +545555444477\nTelefono[1].TelefonoDesc: +559879879879\nDireccion[0].DireccionDesc: Avenida 293 #445\n```\n\n## Contulta para verificar las personas en SQL Server\n```sql\nSELECT per.Id, per.NombreYApellido, per.Edad, \n  Telefonos =  STUFF((SELECT ' || ' + tel.TelefonoDesc\n                      FROM Telefonos tel\n                      WHERE tel.IdPersona = per.id\n                      FOR XML PATH('')), 1, 2, ''),\n  Direcciones = STUFF((SELECT ' || ' + dir.DireccionDesc\n                       FROM Direcciones dir\n                       WHERE dir.IdPersona = per.id\n                       FOR XML PATH('')), 1, 2, '')\nFROM Personas per\n```\n## Seguridad\n[Documento de Microsoft](https://docs.microsoft.com/en-us/odata/webapi/odata-security)\n\n## Links del video\n- Ejemplos OData: https://github.com/OData/ODataSamples\n- URL OData: http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_URLComponents\n\n\n\n------------\n#### Programando Ideas 2020\n\u003cp\u003e\n  \u003ca href=\"https://paypal.me/lp8126\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://www.paypalobjects.com/es_XC/MX/i/btn/btn_donateCC_LG.gif\" border=\"0\" alt=\"Donar con PayPal\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n","funding_links":["https://paypal.me/lp8126"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogramando-ideas%2Fwebapi_odata_ef","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprogramando-ideas%2Fwebapi_odata_ef","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogramando-ideas%2Fwebapi_odata_ef/lists"}