0

We've been using the Entity framework-code first approach and Fluent Api, and have this requirement, an entity with multiple navigation properties and the possibility of numerous entries.

This entity reflects the data of a process and a field captures whether the entity is active in the process. I've provided an example for this.

    public class ProcessEntity
    {
        //Other properties and Navigation properties

        public bool IsInProcess { get; set; }
    }

What I've been trying to do is, have an another table could be a mapping table or something that will contain only the ProcessEntity items whose IsInProcess property is set to true, ie.,this table provides the ProcessEntities that are active in the process.

The whole idea and thought behind this segregation is that, a lot of queries and reports are generated only on the items that are still in process and querying the whole table every time with a Where clause would be a performance bottleneck. Please correct me If I'm wrong. I thought of having a mapping table but the entries have to be manually added and removed based on the condition.

Is there any other solution or alternative design ideas for this requirement?

KDR
  • 478
  • 6
  • 19

1 Answers1

1

Consider using an index. Your second table is what an index would do. Let the DB do its job.

Given that a boolean isnt a great differentiator, a date or similiar as part of the index may also be useful.

eg How to create index in Entity Framework 6.2 with code first

Community
  • 1
  • 1
phil soady
  • 11,043
  • 5
  • 50
  • 95