EntityFramework-Plus check if data implements an interface

c# entity-framework entity-framework-plus

Question

I've got a filter.

 this.Filter<BaseModel>(q => q.Where(x => x.CompanyId == companyId);

Is there a method to determine what implementation of my unique interface "IGlobalDatabaseObject" "x" is being used?

 this.Filter<BaseModel>(q => q.Where(x => x.CompanyId == companyId || x is IGlobalDatabaseObject ); ?

Consequently, the database queries will return the data if the data implements the Global Interface or if "x.CompanyId== companyId."

I use the EntityFramework-Plus package (github.com/zzzprojects).

1
0
7/6/2017 11:08:56 AM

Accepted Answer

You may be looking for Enable/Disable Query Filter for EF+ feature, in my opinion. Say anything like this in your situation:

// The key identifying your filter
var key = new object();

// Create filter for classes that inherit BaseModel
this.Filter<BaseModel>(key, q => q.Where(x => x.CompanyId == companyId));

// Disable the filter for classes that implement IGlobalDatabaseObject
this.Filter<IGlobalDatabaseObject>(key).Disable();
2
7/6/2017 11:54:31 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow