我得到了以下具有有效关系的表,如下所示:

 Report
      ------>ReprotDataSource
                --------->SharePointDomain

现在,当我尝试以下内容(将新的roptdatasource链接到选定的SharePointDomain)时,它会插入新的SharePointDomain记录,而不是使用ID(2)将其转换为SharePointDomain

//Create new Object
ReportDataSource rprtDS = new ReportDataSource
{
  Name = rprtDSSelected.Name,
  Parent = rprtDSSelected.Parent,
  CreatedBy = Environment.UserName,
  CreationDate = DateTime.Now,
  Source = rprtDSSelected.Source,
  Type = rprtDSSelected.Type
};

  if (rprtDS.Type == "SP List")
  //here is the issue
  rprtDS.SharePointDomain = selectedSharePointDomain;//its id = 2
  //Add to EntitySet
  TheReport.ReportDataSources.Add(rprtDS);
  TheReport.Save();

当我将ID设置为(2)时,它可以正常工作

有任何解释。

先感谢您。

有帮助吗?

解决方案

您要添加的对象必须来自相同的数据字母,否则它将算作隐式插入物。我猜这个物体来自其他地方。也许是先前的数据文本。如果您在查询之间缓存对象,这很棘手。也许只是设置ID ...:P

您可能会在必要时感到高兴和依恋,但这可能不值得。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top