Created
July 18, 2014 11:18
-
-
Save AlbertoMonteiro/1f0f0db163a4d1877633 to your computer and use it in GitHub Desktop.
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.Data.Entity; | |
using System.Data.Entity.ModelConfiguration.Conventions; | |
namespace ConsoleApplication2 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
using (var ctx = new Ctx()) | |
{ | |
var contaAReceber = new ContaAReceber(); | |
contaAReceber.Valor = 100; | |
contaAReceber.NFSe = new NotaFiscalEletronicaServico(); | |
contaAReceber.NFSe.Valor = 200; | |
ctx.ContaARecebers.Add(contaAReceber); | |
ctx.SaveChanges(); | |
} | |
} | |
} | |
public class Ctx : DbContext | |
{ | |
public DbSet<ContaAReceber> ContaARecebers { get; set; } | |
public DbSet<NotaFiscalEletronicaServico> NotaFiscalEletronicaServicos { get; set; } | |
protected override void OnModelCreating(DbModelBuilder modelBuilder) | |
{ | |
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>(); | |
base.OnModelCreating(modelBuilder); | |
} | |
} | |
public class ContaAReceber | |
{ | |
public int Id { get; set; } | |
public decimal Valor { get; set; } | |
public NotaFiscalEletronicaServico NFSe { get; set; } | |
} | |
public class NotaFiscalEletronicaServico | |
{ | |
public int Id { get; set; } | |
public decimal Valor { get; set; } | |
public ContaAReceber ContaAReceber { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment