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.Linq; | |
namespace Metavision.Infra.Data | |
{ | |
public interface IUnitOfWork : IDisposable | |
{ | |
T Find<T>(params object[] keyValues) where T : class , new(); | |
/// <summary> |
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; | |
namespace Metavision.Infra.Data | |
{ | |
public interface IRepositorio : IDisposable | |
{ | |
bool HasChanges { get; set; } | |
IUnitOfWork UnitOfWork { get; } | |
} |
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 Metavision.Infra.Data; | |
namespace Metavision.Infra.Extensions | |
{ | |
public static class DataExtensions | |
{ | |
#region extensoes para Repositório |
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.Data; | |
namespace Metavision.Infra.Data | |
{ | |
public abstract class UnitOfWorkBase : IDisposable | |
{ | |
protected readonly Stack<IRepositorio> StackRepositories | |
= new Stack<IRepositorio>(); |
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.Reflection; | |
namespace Metavision.Infra | |
{ | |
/// <summary> | |
/// Service Locator simples | |
/// </summary> |
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.Data; | |
using System.Data.Entity; | |
using System.Data.Entity.Infrastructure; | |
using System.Data.Objects; | |
using System.Linq; | |
namespace Metavision.Infra.Data | |
{ | |
/// <summary> |
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 DemonstrarEntityFramework() | |
{ | |
var dbContext = new MyEntities(); //instancia um dbContext | |
var uow = new CodeFirstUnitOfWork(dbContext); //instancia um unit_of_work para coordenar repositórios | |
var repositorioPessoas = new Repositorio<Pessoa>(uow); //cria um novo repositório passando o unitOfWork | |
var repositorioEnderecos = new Repositorio<Endereco>(uow);//cria um novo repositório passando o unitOfWork | |
var novaPessoa = repositorioPessoas.CreateNew(); //fabrica uma nova entidade | |
novaPessoa.Nome = "Jone Polvora"; //seta o valor do campo Nome |
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
//POST: http://silverlightrush.blogspot.com/2011/11/receita-de-bolo-para-ef-code-first-e.html | |
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel.DataAnnotations; | |
using System.Data.Common; | |
using System.Data.Entity; | |
using System.Data.Entity.Infrastructure; | |
using System.Linq; | |
using Oracle.DataAccess.Client; |
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
CREATE TABLE "PESSOAS" | |
( "ID" NUMBER, | |
"NOME" VARCHAR2(50), | |
CONSTRAINT "PESSOAS_PK" PRIMARY KEY ("ID") ENABLE | |
) | |
/ | |
CREATE TABLE "TELEFONES" | |
( "ID" NUMBER NOT NULL ENABLE, | |
"PESSOA_ID" NUMBER NOT NULL ENABLE, | |
"NUMERO" VARCHAR2(10) NOT NULL ENABLE, |
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
// Created by por Jone Polvora | |
// Twitter: @jpolvora | |
// WebSite: http://silverlightrush.blogspot.com | |
// Based on Dynamic Decorator / CBO Extender Project (http://www.codeproject.com/Articles/275292/Component-Based-Object-Extender) | |
// Depends on Impromptu-Interface (https://code.google.com/p/impromptu-interface/_ | |
// Last Update: 21/05/2012 10:40AM GMT -04:00 | |
// Brazil | |
/* USAGE EXAMPLE |
OlderNewer