This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace PuntoTechApp | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.WriteLine("¡Os damos la bienvenida a PuntoTechApp!"); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace PuntoTechApp | |
{ | |
public class BaseEntity | |
{ | |
public int Id { get; set; } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace PuntoTechApp | |
{ | |
public class Post : BaseEntity | |
{ | |
public string Title { get; set; } | |
public string Url { get; set; } | |
public int Words { get; set; } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.EntityFrameworkCore; | |
namespace PuntoTechApp | |
{ | |
public class MyContext : DbContext | |
{ | |
public DbSet<Post> Posts { get; set; } | |
protected override void OnConfiguring(DbContextOptionsBuilder options) | |
{ | |
if (!options.IsConfigured) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.EntityFrameworkCore; | |
namespace PuntoTechApp | |
{ | |
public class MyContext : DbContext | |
{ | |
protected override void OnConfiguring(DbContextOptionsBuilder options) | |
{ | |
if (!options.IsConfigured) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<StackPanel Padding="10" | |
Spacing="10"> | |
<TextBlock Text="Windows" /> | |
<StackPanel Orientation="Horizontal" Spacing="10" Padding="10"> | |
<Button Content="Button" /> | |
<Button Content="Button" IsEnabled="False" /> | |
</StackPanel> | |
<TextBlock Text="iOS" /> |