Skip to content

Instantly share code, notes, and snippets.

💭
Software Development is my passion!

Carlos dos Santos carloscds

💭
Software Development is my passion!
View GitHub Profile
View Artigo1407.xml
<connectionStrings>
<add name="Contexto"
connectionString="data source=(local); initial catalog=EFIndice; user id=teste; password=teste"
providerName="System.Data.SqlClient"/>
</connectionStrings>
View Artigo1407_3.cs
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),
View Artigo1407_2.cs
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; }
}
View Artigo1407_1.cs
public class Cliente
{
public int ID { get; set; }
public string Nome { get; set; }
public string Cidade { get; set; }
public string UF { get; set; }
}
View Artigo1407.cs
public class Contexto : DbContext
{
public DbSet<Cliente> Cliente { get; set; }
}
View CountSample.cs
static void Main(string[] args)
{
Stopwatch contador = new Stopwatch();
contador.Start();
var db = new NorthwindContext();
var dados = db.Customers;
foreach(var c in dados)
{
View InjecaoEF_ClienteController.cs
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;
View InjecaoE_EnvioEmail.cs
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";
View Injecao_IEnvioEmail.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace InjecaoDependenciaDiretaEF.Services
{
public interface IEnvioEmail
{
string Enviar();
View InjecaoEF_Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddDbContext<AplicacaoContext>(options =>
options.UseInMemoryDatabase("DBMemory"));
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddScoped<IEnvioEmail, EnvioEmail>();
}
You can’t perform that action at this time.