i have more than one class library + MyWebApplication(UI) that all of these have own object scope provide when i enable OA for each of them.
in one of the class library that is "EandE.Organization.BSL" i have 3 Entity class and their manager class that i used in UI to assign selected ORGPersonJob(s) by User to a specific ORGRole,
class No1 : OrgPersonJob (many-to-many Join Table between 2 class ( OrgPerson and OrgJob ) )
Class No2 : OrgRole
Class No3 : OrgUser (many-to-many Join Table between 2 class ( ORGPersonJob and OrgRole ) )
their Manager :
Manager Class No1 : OrgPersonJobManager
Manager Class No2 : OrgRoleManager
Manager Class No3 : OrgUserManager
after the user select ORGPersonJob(s), in a loop i assign those ORGPersonJob(s) To a Specific ORGRole one by one
that Code that i used for,in my UI like this :
protected void ButtonAssign_Click(object sender, EventArgs e)
{
ORGPersonJob PersonJob;
List<ORGUser> UsersList = new List<ORGUser>();
ORGUser User;
ORGRole Role = new ORGRole();
UserControl userControl = (UserControl)FindControl("ucInternalPersonnel1");
RadGrid RadGridInternalPersonnel = (RadGrid)userControl.FindControl("RadGridInternalPersonnel");
int selectedItemsCount = RadGridInternalPersonnel.SelectedItems.Count;
for (int i = 0; i < selectedItemsCount; i++)
{
User = new ORGUser();
int personJobId = Convert.ToInt32(RadGridInternalPersonnel.SelectedItems[i].OwnerTableView.DataKeyValues[i]["Id"]);
PersonJob = orgPersonJonManager.RetrieveOrgPersonJobById(personJobId);
int roleId = Convert.ToInt32(RadComboBoxDocumentRoles.SelectedValue);
Role = orgRoleManager.RetrieveORGRoleById(roleId);
User.ORGPersonJob = PersonJob;
User.ORGRole = Role;
UsersList.Add(User);
}
if (selectedItemsCount != 0)
{
**** orgRoleManager.RegisterNewRoleUsers(Role, UsersList);
}
}
i have no problem until Marked Line that i call a manager Role Class that is in My Business Class Library "EandE.Organization.BSL" :
the code of function "orgRoleManager.RegisterNewRoleUsers" is like This :
public void RegisterNewRoleUsers(ORGRole role, List<ORGUser> usersList)
{
scope.Transaction.Begin();
for (int i = 0; i < usersList.Count; i++)
{
**** role.ORGUsers.Add(usersList[i]);
}
scope.Transaction.Commit();
}
but when i achieve to marked line i have an exception that i shown below :
" Object references between two different object scopes are not allowed. The object 'EandE.Organization.BSL.Entities.ORGPersonJob' is already managed by 'ObjectScopeImpl 0xa4b12 Telerik.OpenAccess.RT.ObjectScope' and was tried to be managed again by 'ObjectScopeImpl 0x1cf3235 Telerik.OpenAccess.RT.ObjectScope'. "
also for test i add a property ro classes that i used with name "GetObjectScope" which returned the related Class`s objectscope like this
public IObjectContext Scope
{
get
{
return Database.GetContext(this);
}
}
and in my business function i use this :
public void RegisterNewRoleUsers(ORGRole role, List<ORGUser> usersList)
{
//scope = (IObjectScope)role.Scope;
scope.Transaction.Begin();
for (int i = 0; i < usersList.Count; i++)
{
**** role.ORGUsers.Add(usersList[i]);
}
scope.Transaction.Commit();
}
but i have mentioned exception again in marked line
what is your solution?
tanks