I have a database relationship as shown below. The domain objects are created based on LINQ to SQL ORM. 

A payment comprises of Cash Payment and Gift Coupon Payments. Suppose the total amount of purchase is 550. It can be paid as following components

```
1 Gift Coupon Valued 300

1 Gift Coupon Valued 200

I Cash Currency Valued 50

```

![enter image description here](https://i.stack.imgur.com/1ZxQH.jpg)

I am inserting new payment records using the “InsertOnSubmit” function of ORM. The following code is working fine. However, if I the company is introducing a new payment component using credit card, I need to make changes to my “Payment” domain class. How do I make the payment class **Open for Extension and Closed for Changes** still using **ORM**?

Note: The Payment class has **behaviors** (E.g. GetTotalAmountCollected). I am trying to make the "Payment" class to satisfy OCP.

Note: There is a specific **behavior** for Coupon type. Is the Coupon issued date is less than 1/1/2000, it should not be used in calculation for Total Amount (i.e, CouponValue should be zero). Refer [Refactoring code using Strategy Pattern](https://stackoverflow.com/questions/11435320/refactoring-code-using-strategy-pattern) also.

Note: I am using **.Net 4.0**

Reference: 

1. [Getting an error when using ObjectContext.AddObject with Entity Framework](https://stackoverflow.com/questions/1174394/getting-an-error-when-using-objectcontext-addobject-with-entity-framework)
2. [Refactoring code using Strategy Pattern](https://stackoverflow.com/questions/11435320/refactoring-code-using-strategy-pattern)
3. [Prefer composition over inheritance?](https://stackoverflow.com/questions/49002/prefer-composition-over-inheritance)
4. [Code-first vs Model/Database-first](https://stackoverflow.com/questions/5446316/ef-4-1-code-first-vs-model-database-first)
5. [Strategy Pattern and Dependency Injection using Unity](https://stackoverflow.com/questions/1706056/strategy-pattern-and-dependency-injection-using-unity)
6. [C# Strategy Design Pattern by Delegate vs OOP](https://stackoverflow.com/questions/984050/c-sharp-strategy-design-pattern-by-delegate-vs-oop)
7. [How to use the Strategy Pattern with C#?](https://stackoverflow.com/questions/3449634/how-to-use-the-strategy-pattern-with-c)
8. Inheritance with EF Code First: Part 2 – Table per Type (TPT)
<http://weblogs.asp.net/manavi/archive/2010/12/28/inheritance-mapping-strategies-with-entity-framework-code-first-ctp5-part-2-table-per-type-tpt.aspx>

C# Code:

```
public class PaymentAppService
{
    public RepositoryLayer.ILijosPaymentRepository Repository { get; set; }

    public void MakePayment()
    {
        DBML_Project.Payment paymentEntity = new DBML_Project.Payment();
        paymentEntity.PaymentID = 1;
        paymentEntity.PaymentType = "PurchaseP";

        DBML_Project.CashPayment cashObj = new DBML_Project.CashPayment();
        cashObj.CashPaymentID = 1;
        cashObj.CurrencyNumber = 123;
        cashObj.CurrencyValue = 100;

        DBML_Project.GiftCouponPayment giftCouponObj = new DBML_Project.GiftCouponPayment();
        giftCouponObj.GiftCouponPaymentID = 1;
        giftCouponObj.CouponValue = 200;
        giftCouponObj.CouponNumber = 124;

        paymentEntity.CashPayments = new System.Data.Linq.EntitySet<DBML_Project.CashPayment>();
        paymentEntity.CashPayments.Add(cashObj);

        paymentEntity.GiftCouponPayments = new System.Data.Linq.EntitySet<DBML_Project.GiftCouponPayment>();
        paymentEntity.GiftCouponPayments.Add(giftCouponObj);

        Repository.InsertEntity(paymentEntity);
        Repository.SubmitChanges();
    }
}

```

Repository:

```
public class LijosPaymentRepository : ILijosPaymentRepository
{
    public System.Data.Linq.DataContext MyDataContext { get; set; }

    public void InsertEntity(DBML_Project.Payment payment)
    {
        //Insert the entity
        MyDataContext.GetTable<DBML_Project.Payment>().InsertOnSubmit(payment);
    }

    public void SubmitChanges()
    {
        MyDataContext.SubmitChanges();
    }
}

```