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
<connectionStrings> | |
<add name="Contexto" | |
connectionString="data source=(local); initial catalog=EFIndice; user id=teste; password=teste" | |
providerName="System.Data.SqlClient"/> | |
</connectionStrings> |
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
public partial class CriacaoBanco : DbMigration | |
{ | |
public override void Up() | |
{ | |
CreateTable( | |
"dbo.Clientes", | |
c => new | |
{ | |
ID = c.Int(nullable: false, identity: true), | |
Nome = c.String(maxLength: 100), |
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
public class Cliente | |
{ | |
public int ID { get; set; } | |
[Index] | |
[MaxLength(100)] | |
public string Nome { get; set; } | |
public string Cidade { get; set; } | |
public string UF { 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
public class Cliente | |
{ | |
public int ID { get; set; } | |
public string Nome { get; set; } | |
public string Cidade { get; set; } | |
public string UF { 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
public class Contexto : DbContext | |
{ | |
public DbSet<Cliente> Cliente { 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
static void Main(string[] args) | |
{ | |
Stopwatch contador = new Stopwatch(); | |
contador.Start(); | |
var db = new NorthwindContext(); | |
var dados = db.Customers; | |
foreach(var c in dados) | |
{ |
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; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using InjecaoDependenciaDiretaEF.Data; | |
using InjecaoDependenciaDiretaEF.Models; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.EntityFrameworkCore; | |
using Microsoft.Extensions.Logging; |
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; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
namespace InjecaoDependenciaDiretaEF.Services | |
{ | |
public class EnvioEmail : IEnvioEmail | |
{ | |
public string Enviar() => "Email Enviado"; |
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; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
namespace InjecaoDependenciaDiretaEF.Services | |
{ | |
public interface IEnvioEmail | |
{ | |
string Enviar(); |
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
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddControllers(); | |
services.AddDbContext<AplicacaoContext>(options => | |
options.UseInMemoryDatabase("DBMemory")); | |
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>(); | |
services.AddScoped<IEnvioEmail, EnvioEmail>(); | |
} |
NewerOlder