Hi Greg,
If you want to apply a filter to all queries (do you mean all queriable entities?) you can create the filter dynamically with PredicateDescription:
protected override bool FilterQuery() {
var typesList = this.EntityManager.MetadataStore.GetEntityTypes();
foreach (var type in typesList) {
var meta= IdeaBlade.EntityModel.EntityMetadataStore.Instance.GetEntityMetadata(type);
var oId = meta.DataProperties["OwnerId"];
if (oId != null) { // you might not want to filter entities with no "OwnerId" field
var currentUser = this.GetCurrentAppUserEntity();
if (currentUser != null) {
var filter = new PredicateDescription(type, "OwnerId", FilterOperator.IsEqualTo, currentUser.Id);
this.QueryFilters.AddFilter(filter);
//QueryFilters.AddFilter<ContactEntity>(q => q.Where(c => c.OwnerId == currentUser.Id));
} else {
//Will return no records.
var filter = new PredicateDescription(type, "OwnerId", FilterOperator.IsEqualTo, -1);
this.QueryFilters.AddFilter(filter);
//QueryFilters.AddFilter<ContactEntity>(q => q.Where(c => c.OwnerId == -1));
}
return base.FilterQuery();
}
I hope this helps,
Silvio.