Skip to content

Instantly share code, notes, and snippets.

View carloscds's full-sized avatar
💭
Looking forward, everyday!

Carlos dos Santos carloscds

💭
Looking forward, everyday!
View GitHub Profile
<connectionStrings>
<add name="Contexto"
connectionString="data source=(local); initial catalog=EFIndice; user id=teste; password=teste"
providerName="System.Data.SqlClient"/>
</connectionStrings>
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),
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; }
}
public class Cliente
{
public int ID { get; set; }
public string Nome { get; set; }
public string Cidade { get; set; }
public string UF { get; set; }
}
public class Contexto : DbContext
{
public DbSet<Cliente> Cliente { get; set; }
}
static void Main(string[] args)
{
Stopwatch contador = new Stopwatch();
contador.Start();
var db = new NorthwindContext();
var dados = db.Customers;
foreach(var c in dados)
{
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;
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";
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace InjecaoDependenciaDiretaEF.Services
{
public interface IEnvioEmail
{
string Enviar();
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddDbContext<AplicacaoContext>(options =>
options.UseInMemoryDatabase("DBMemory"));
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddScoped<IEnvioEmail, EnvioEmail>();
}