Hello,
We are writing a new application and would like to use the Context object. Meaning would be that we have only 1 instance of every object in our application so that when we change the name of an customer in one screen, all other form that display this name would follow.
I've been playing around with the Context and have some problems and some questions. I hope you can help me out.
First a question; in the manual there is stated: A context shouldn't be used as a cache, nor should it kept alive for a long time, just long enough for the semantic context to use unique objets in. Is it a problem if my semantic context is the entire lifecycle of my application?
Now the problems:
I'm using a global static Context object to hold all entities fetched. I'm able to have multiple forms that work together on the same entity. I have code like this
DepartmentEntity department = new DepartmentEntity(5);
adapter.FetchEntity(department);
department = (DepartmentEntity)Form1.Context.Get(department);
First I used the following code, but this didn't work...
DepartmentEntity department = new DepartmentEntity(5);
adapter.FetchEntity(department, Form1.Context);
Can you please explain me why it doesn't work or what I'm missing about the context?
The second problem is with a collection. I have following code:
adapter.FetchEntityCollection(Departments, null);
Form1.Context.Add(Departments);
When I first load my collection and then my separate department entity, the entities from the collection (shown in a grid) follow the entities from the separate forms. However, if I reverse the working order and first load a single department followed by all departments and add them to the context, they don't follow any more.... So it seams that I have 2 different kind of references. With single entities I can do the trick with Context.Get (which I don't like) but how to fix this with collections?
Again, can you please tell me what I'm missing or doing wrong?
Kind regards
TomV