1

I have a problem. I have one to many relation in a database and I want to use interfaces.

How I can realize this?

[Table("CashRegister")]
public class CashRegister : ICashRegister
{
    [DataMember]
    [Key]
    public Guid Id { get; set; }
    [DataMember]
    public double Sum { get; set; }
    [DataMember]
    public string Name { get; set; }
    [DataMember]
    public Guid CurrencyId { get; set; }

    [DataMember]
    [ForeignKey("CurrencyId")]
    public ICurrency Currency { get; set; }       
}
public interface ICashRegister 
{
    [Key]
    Guid Id { get; set; }
    string Name { get; set; }
    Guid CurrencyId { get; set; }
    [ForeignKey("CurrencyId")]
    ICurrency Currency { get;set; }
    double Sum { get; set; }

}
2
  • possible duplicate of error when using interfaces for Entity Framework (4.2) entities (Still applies) Commented Jul 10, 2014 at 22:28
  • Unforutnately, @GertArnold is right. I believe that EF7 will support Dependency Injection, however and will allow you to do define concrete mappings to interfaces... But that's a ways out yet. Commented Jul 10, 2014 at 22:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.