I've got a table "Expenses" that contains an FK value to an "ExpenseType" table. Right now, if I want to save a new expense, I first get the int value of the FK, do a lookup to the ExpenseType table, and assign the object to the expense object. For example:
//create new expense
var e = new Expense();
//lookup the associated expense type
var et = context.ExpenseTypeSet.First(e -> e.expenseTypeID == 10);
//set field values
e.expenseName = "Some name";
e.expenseType = et;
//save
context.Save();
Is there a way to create/insert a record without first being forced to do a lookup against the FK table? The lookup is not needed and forces extra database hits. I already know the FK ID... so is there a way to just set the ID and allow it to be happy?
Thanks in advance -