Question: I have the following models (simplified leaving all other fields out, focusing on primary key ID's):

```
[invoice]
 invoice_id
 customer_id
 invoice_description

[customer]
  customer_id
  company_id
  customer_name

[company]
 company_id
 company_name

[strategy]
 strategy_id
 strategy_descripton

```

A company contains many customers, which in turn can have many invoices belonging to that customer.

Although not shown above, I also wish to have a list of strategies, that belong to a company (and only one company).

I would like the customer, invoice, and company, to be able to define a 'default strategy' which references a strategy of the company to which they belong.

I know i could put an extra FK field called strategy\_id in each table (invoice, customer and company), but how can i ensure that if changes are made (someone tries to move a strategy to a different company) we do not end up with an invoice, or customer pointing to a strategy that belongs in another company's strategy list?

How would i deal with this - Do i need to check all this in business logic, or use check constraints, or can this be achieved through table redesign and foreign keys?

Many thanks in advance,

Chris

Answer: 
try

```
var transactions = from t in db.Transactions
                    where t.SellingPrice != 0 
                    select t;

```
```
var transactions = (from t in db.Transactions
                        select new
                       {
                           t.SellingPrice,
                           t.CommissionPercent,
                           ...,
                           ...,
                           t.Etc...
                       }).AsEnumerable().Select(x => new HomeModel // Create a model which have following properties
                        {
                           SellingPrice= x.SellingPrice,  //(where SellingPrice is a HomeModel property)
                           AdCategoryTitle = x.CommissionPercent,
                           ...,
                           ...,
                           ETc... = t.Etc...
                       }).ToList();

```