Skip to content

Instantly share code, notes, and snippets.

View Beelzenef's full-sized avatar
馃摎
coding + learning

Elena Beelzenef

馃摎
coding + learning
View GitHub Profile
@Beelzenef
Beelzenef / base_entity.cs
Created May 3, 2020 09:30
Entidad base para EF Core en medium.com/puntotech
namespace PuntoTechApp
{
public class BaseEntity
{
public int Id { get; set; }
}
}
@Beelzenef
Beelzenef / initial_app.cs
Last active May 3, 2020 09:59
Ejemplo de aplicaci贸n de consola para medium.com/puntotech
using System;
namespace PuntoTechApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("隆Os damos la bienvenida a PuntoTechApp!");
@Beelzenef
Beelzenef / app_linq.cs
Last active August 24, 2020 08:25
Ejemplo de LINQ, para medium.com/puntotech
using System;
// Paso 1: Referencia a Linq para poder usarlo en nuestro software
using System.Linq;
namespace PuntoTechApp
{
class Program
{
static void Main(string[] args)
{
@Beelzenef
Beelzenef / efcore_createpost.cs
Last active August 2, 2020 20:53
Proceso de crear una nueva entidad, para medium.com/puntotech
// Paso 1: Operaci贸n CREATE para la BD
private int CreatePost(Post newPost)
{
int result = 0
if (newPost != null)
{
ctx.Posts.Add(newPost);
result = ctx.SaveChanges();
@Beelzenef
Beelzenef / efcore_updatepost.cs
Last active August 2, 2020 19:36
Proceso de actualizar entidad, para medium.com/puntotech
// Paso 1: Obtener una entidad por ID
private Post GetPost(int postToSearchId)
{
if (postToSearchId != 0)
{
IQueryable<Post> entitiesInSearch = ctx.Posts
.Where(p => p.Id == postToSearchId)
Post postToSearch = entitiesInSearch.SingleOrDefault()
return postToSearch;
@Beelzenef
Beelzenef / efcore_dbcontext_rels.cs
Last active August 24, 2020 08:23
Crear relaci贸n entre entidades, para medium.com/puntotech
using Microsoft.EntityFrameworkCore;
namespace PuntoTechApp
{
public class MyContext : DbContext
{
public DbSet<Posts> Posts { get; set; }
// Modificaci贸n: a帽adir colecci贸n de Authors
public DbSet<Authors> Authors { get; set; }
@Beelzenef
Beelzenef / efcore_post_withauthor.cs
Last active August 24, 2020 08:24
Modificaci贸n de entidad Post, creando relaci贸n con entidad Author, para medium.com/puntotech
namespace PuntoTechApp
{
public class Post : BaseEntity
{
public string Title { get; set; }
public string Url { get; set; }
public int Words { get; set; }
// Modificaci贸n: conexi贸n con Author
public int AuthorId { get; set; }
@Beelzenef
Beelzenef / efcore_author.cs
Last active August 24, 2020 08:24
Definici贸n de entidad Author, para medium.com/puntotech
namespace PuntoTechApp
{
public class Author : BaseEntity
{
public string Username { get; set; }
public string Name { get; set; }
// Posts escritos por Author
public int ICollection<Post> Posts { get; set; }
}
provider "azurerm" {
version = "=2.40.0"
features {}
}
resource "azurerm_resource_group" "resgroup" {
name = "newfunctionapp-rg"
location = "West Europe"
}
# Task: Terraform init
- task: petergroenewegen.PeterGroenewegen-Xpirit-Vsts-Release-Terraform.Xpirit-Vsts-Release-Terraform.Terraform@2
displayName: 'Terraform init'
inputs:
TemplatePath: '$(System.DefaultWorkingDirectory)/_NombreArtifact/Terraform'
Arguments: init
InstallTerraform: true
UseAzureSub: true
ConnectedServiceNameARM: 'Conexi贸n a Azure'