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
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSingleton<IServico, Servico>();
services.AddSingleton<ExecutaServico, ExecutaServico>();
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace InjecaoDependenciaDiretaEF.Models
{
public class Cliente
{
public int Id { get; set; }
using InjecaoDependenciaDiretaEF.Models;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace InjecaoDependenciaDiretaEF.Data
{
public class AplicacaoContext : DbContext
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddDbContext<AplicacaoContext>(options =>
options.UseInMemoryDatabase("DBMemory"));
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddScoped<IEnvioEmail, EnvioEmail>();
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace InjecaoDependenciaDiretaEF.Services
{
public interface IEnvioEmail
{
string Enviar();
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;
using InjecaoDependenciaDiretaEF.Data;
using InjecaoDependenciaDiretaEF.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
static void Main(string[] args)
{
Stopwatch contador = new Stopwatch();
contador.Start();
var db = new NorthwindContext();
var dados = db.Customers;
foreach(var c in dados)
{
public class Contexto : DbContext
{
public DbSet<Cliente> Cliente { 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; }
}