我正在尝试将以下代码实现到 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);
}