我得到了以下具有有效关系的表格,如下所示:
Report
------>ReprotDataSource
--------->SharePointDomain
现在,当我尝试以下操作(将新的 ReprotDataSource 链接到选定的 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) 时,它工作正常
任何解释。?
先感谢您。