Hello! My name is Pat and I am having an issue when working with llblgen and a state machine workflow. I think it could possibly be a serialization error, but I am hoping for some guidance.
I have a state machine workflow and it binds to two activities in an event. The first activity binds to an object of type RequestEntity. The second activity binds to a child of RequestEntity which is an EntityCollection<CommentEntity>;
Activity 1 binds to RequestEntity.
Acitivity 2 binds to RequestEntity.Comment[0]
My code that runs before the call to the workflow looks like this.
Request request = Fetch(Request and all child objects including Comments)
CommentEntity comment = new CommentEntity();
comment.Active = true;
comment.CommentDate = DateTime.Now;
comment.StaffComments = "This request was reassigned from ";
comment.UserId = _userId;
request.ReqComment.Add(comment);
Once I have added the comment to the request I pass it into the workflow. This is where the issue takes place.
If the request had no comments in the database and returned with a property of Comment = null, I add the comment manually and the workflow gets an error of 'Index out of bounds' when trying to access the comment.
If the request had comments in the database and the Comments collection comes back from the fetch instantiated and then I add the comment manually the workflow runs correctly and returns. (I verified that the comment that i added manually is the comment that gets passed into the workflow)
The question is why does the workflow have a problem accessing the comment when I instantiate and .Add the comment manually? Is there a difference in how the EntityCollections get instantiated when a Fetch is called? Do they get serialized differently? Or possibly is there a difference in that one is 'PassedByReference' and one is 'PassedByCopy'
Any help would be greatly appreciated!
Thanks!
Pat