1

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

1 回答 1

0

的实现ExpenseReport没有set属性,只有属性get。这意味着您不能运行以下行:

this.ExpenseReport = this.DataWorkspace.ApplicationData.ExpenseReports_SingleOrDefault(this.ExpenseReportId);

能改成ExpenseReport可写吗?

于 2013-04-18T18:15:06.743 回答