I'm trying to implement the following code into a LightSwitch 2012 project. I'm getting an error when I try to assign the this.ExpenseReport to a value. The error reads "Property or indexer 'LightSwitchApplication.ExpenseReportDetails.ExpenseReport' cannot be assigned to -- it is read only".
partial void ExpenseReportDetails_InitializeDataWorkspace(List<IDataService> saveChangesTo)
{
// Write your code here.
if (this.ExpenseReportId == -1) // -1 means new Report
{ // Create a new ExpenseReport
this.ExpenseReport = new ExpenseReport();
}
else
{
// Get existing Expense Report
this.ExpenseReport = this.DataWorkspace.ApplicationData.ExpenseReports_SingleOrDefault(this.ExpenseReportId);
// Set the name of the Tab to the default field on the Entity
this.SetDisplayNameFromEntity(this.ExpenseReport);
}