无法在LightSwitch 2012项目中分配值

时间:2013-04-18 18:10:10

标签: lightswitch-2012

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

1 个答案:

答案 0 :(得分:0)

ExpenseReport的实施没有set属性,只有get属性。这意味着您无法运行以下行:

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

您可以将ExpenseReport更改为可写吗?