UPDATE -----------
I just realized the LLBL is getting confused on the order of the fields. In the database, the fields are IdeaId, FacetId. The LLBL designer has them the other way around. Telling LLBL to look again didn't do it, but dropping the entity mapping, and recreating it did. Frustrating...
UPDATE -----------
I'm using 2.6 Final from Oct 9.
I have 3 entities. Idea, IdeaFacet, and Facet.
The ids are guids.
Below, I've included the relevant pieces of a method from my partial IdeaEntity class.
public bool UpdateFrom(IdeaEntity ideaToUpdateFrom)
{
// remove all facets that aren't in the ideaToUpdateFrom
var facetsToDelete = (from ideaFacet in IdeaFacets
where !ideaToUpdateFrom.IdeaFacets.Any(idF=> idF.FacetId == ideaFacet.FacetId)
select ideaFacet).ToList();
facetsToDelete.ForEach(entity => IdeaFacets.Remove(entity));
// add all of the facets that don't already exist.
var facetsToAdd = (from ideaFacet in ideaToUpdateFrom.IdeaFacets
where !IdeaFacets.Any(idF=> idF.FacetId == ideaFacet.FacetId)
select ideaFacet).ToList();
foreach (var I in facetsToAdd)
{
// Attempt 1: I.Idea = this;
// Attempt 2: var newIdeaFacet = new IdeaFacetEntity(){Idea=this, FacetId = I.FacetId};
//Attempt 3: IdeaFacets.Add(newIdeaFacet);
//newIdeaFacet.FacetId = I.FacetId;
}
return true;
}
The ideaToUpdateFrom is coming in with values I want to use to overwrite my existing idea's data. Everything works fine, until I try to add related facets. (See the commented out code). Every one of my attempts to transfer the FacetId from the update entity to the persistent entity is failing. What's happening is that so long as I'm just dealing purely with an IdeaFacetEntity, unattached to an Idea, I can set the FacetId. As soon as I point it to my idea, the FacetId changes. In attempt 3, you can see that I tried setting the facetid after the idea. That set the facet, but unset the Idea.
What am I missing here?
Thanks.