This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Good day Every time I do a Find to my UOW on Postgresql function it returns the same Data, no matter what I do, although the Parameters change everytime I execute the UOW.Find(query). But when I do create a new UOW by: UOW = LigthSpeedContext.CreateUnitOfWork(); It works fine, so my conclusion is that I need to do a call to my Postgesql db every time I execute a Function(Store Proc) is this correct or am I doing something wrong? Please Help Thanks Stiaan Bellow is my code:
ProcedureParameter param1= new ProcedureParameter("Param1", SelectedCarrier.Carriernumber.ToString());
ProcedureParameter param2= new ProcedureParameter("Parm2", SelectedOptionplan.Optionnumber.ToString());
ProcedureQuery procedureQuery = new ProcedureQuery("FunctionName", param1, param2);
var obj = new ObservableCollection<Entity>(uwRecord.Find<Entity>(procedureQuery)); |
|
|
This is probably occurring because entities that are already present in the UOW are returned from the L1 cache rather than materialising new entities. This behaviour is by design. I would guess that your stored procedure is returning the same IDs each time, but with different data. E.g. the first time you call it it returns ID=1, Name='bob', the second time ID=1, Name='kate'. In this case LightSpeed consults the UOW for a Person with ID 1. On the second query, LightSpeed finds that it's already there. So it returns that existing entity instance (where the Name is 'bob') rather than creating a new entity instance with the same ID but a different Name. If you want to get the latest version of the data for the same ID, you must either load the entities into a new unit of work, or flush and clear the existing entities from the current unit of work by calling SaveChanges(true). |
|