Global filtering over all entities with some weird method for DBFirst
Well, all filtering approaches already exists in tutorials are done with Code First approach. I need to filter data dynamically and came up with that shitty solution.
Usage tips;
Create another partial class of your main dbcontext class which is generated by EF tools. And also create a constructor and provide your filter value with a property. Such as;
public BlaBlaEntities(int? appliedFilterID)
: base("name=BlaBlaEntities")
{
if (appliedFilterID.HasValue)
{
this.FilterID = appliedFilterID.Value;
}
}
public int FilterID { get; set; }
That way you can pass filter parameter optinally according to the method you like to filter. Hope helps.