Hi
I have an Entity set that has Entities with a compound key containing ID (GUID) and CreatedAt (DateTime). This CreatedAt is when the entity was created. Each record represents each version of each entity such that muliple records can have the same ID.
I want to create an IQuerable-returning method that I can re-use such that it will only return the latest version of the entity requested, but I'm struggling to find the answer (if, indeed, there is an answer).
I know that I can write a query such as
(from e in context.Entities where e.ID = myID orderby e.CreatedAt).FirstOrDefault();
But I want to be able to do this instead:
(from e in context.GetCurrentEntities() where e.ID = myID).FirstOrDefault();
Such that it will only return the latest versions of the entity required.
Is this doable?
Many thanks for your help.
Lee