我正在尝试将以下代码实现到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);
}
答案 0 :(得分:0)
ExpenseReport
的实施没有set
属性,只有get
属性。这意味着您无法运行以下行:
this.ExpenseReport = this.DataWorkspace.ApplicationData.ExpenseReports_SingleOrDefault(this.ExpenseReportId);
您可以将ExpenseReport
更改为可写吗?