Print Page | Close Window

Creating new one-to-one Entity Pairs

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1786
Printed Date: 21-Apr-2026 at 5:49am


Topic: Creating new one-to-one Entity Pairs
Posted By: chuckc
Subject: Creating new one-to-one Entity Pairs
Date Posted: 05-May-2010 at 8:39am
What's the proper way to create new Entities when they are related one-to-one?
 
The snippet of code below hopefully gives an idea of what I'm trying to do. 
 
public static Company Create(iCatalystEntityManager manager)
{
   Company company = manager.CreateEntity<Company>();
   company.CompanyId = Guid.NewGuid();
   company.Group =
Group.Create(manager);
   //Need to somehow get company.Group.GroupId = company.CompanyId ??
   company.EntityAspect.AddToManager(); // throws exception when Group and Company are one-to-one
   return company;
}
 
I changed my schema to get rid of the one-to-one so I could move on, but I'll need to restore that relationship soon.
 
Thanks!
 



Replies:
Posted By: dkearney1
Date Posted: 05-May-2010 at 12:53pm
company.Group = Group.Create(manager, company.CompanyId);

-------------
Dan
“In anything at all, perfection is finally attained not when there is no
longer anything to add, but when there is no longer anything to take away.”
Saint-Exupéry
Wind, Sand, and Stars



Print Page | Close Window