I got the following Tables with valid relations as shown below:
Report
------>ReprotDataSource
--------->SharePointDomain
Now, when i try the following ( link the newly ReprotDataSource to the Selected SharePointDomain) it insertes a new SharePointDomain Record instead of refrence it to the SharePointDomain with id (2)
//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();
It works fine when i set the id my self to (2)
any explanations.?
Thank you in advance.