I can achieve that in SQL using this:
Code: Select all
SELECT *
FROM ac_Subscriptions A
WHERE EXISTS (SELECT B.UserId
FROM ac_Subscriptions B
WHERE B.UserId = A.UserId
AND B.ExpirationDate < A.ExpirationDate)
OR (SELECT COUNT(*) FROM ac_Subscriptions C
WHERE C.UserId = A.UserId) = 1
How can I do that with the SubscriptionRepository? I'm looking at SubscriptionRepository, BuildSearchCriteria
TIA!