I want to do fast, sub-second joins across a few tables using the Entity Framework (model first). The simplified data model is similar to the following:
Videos: ID (Primary Key); Name
Tags: ID (Primary Key); Name
TaggedVideos: TagID (FK); VideoID (FK)
Is there a way to pre-load TaggedVideos when the table is not modeled or exposed in the Entity Framework? I’m trying to avoid database hits when searching for all videos with a certain tag. Ideally, all three tables would be loaded into collections and I could join then using PLINQ.
If I add another column to TaggedVideos, I can accomplish this but I would prefer an elegant solution that doesn’t clutter the data model.
Any help would be appreciated.
Cache the tags and make sure the have a backward nav-property to the collection of videos.
You can then access your cached version of the tag and look up the associated videos without a join.
If you dont want to cache the whole video, in your caching code select use something like Videos.Select(v=>v.Id) to select just the Ids and cache that.