Я пытаюсь внедрить следующий код в проект LightSwitch 2012. Я получаю сообщение об ошибке, когда пытаюсь присвоить this.ExpenseReport значение. Ошибка гласит: «Свойство или индексатор LightSwitchApplication.ExpenseReportDetails.ExpenseReport не может быть назначено — оно доступно только для чтения».
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);
}