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
|
I have a small problem, in our code we iterate through a list of records, each record contains data the requires updating stock record, financial records etc. Whilst we are iterating through we create a new stock movement record and add it to the uow. Later after we have posted the financial transaction, and we have a reference code, we need to update the stock movement records. I have tried the following code to isolate the new records, but it doesn't work. My question is am I misunderstanding the concept, or am I coding this incorrectly? Thanks
|
|
|
Hi Mark, You can run the query directly on your uow, it implements IEnumerable for all entities currently tracked :-) So uow.Where(e => e.EntityState == EntityState.New) Hope that helps, John-Daniel |
|
|
I John-Daniel, the problem with that is that it shows ALL added entities, not just the StockMovement records. Is there a way to identify which of the return entities are StockMovement ones? Thanks Mark |
|
|
Hi Mark, You could likely optimise this further, but since this is just LINQ to Objects you could write it as uow.Where(e => e.EntityState == EntityState.New && e is StockMovement) I hope that helps, John-Daniel |
|
|
That's great. Thanks |
|