根据关系集合计数过滤 FetchEntityCollection
我目前获取这样的作业集合:
jobs = new EntityCollection<JobEntity>(new JobEntityFactory());
var bucket = GetJobsBucket(filter);
var tempContext = new Context();
tempContext.Add(jobs);
var sorter = new SortExpression(JobFields.Id | SortOperator.Descending);
adapter.FetchEntityCollection(jobs, bucket, maxCount, sorter, JobListPrefetchPath(false));
filter.TotalMatchesCount = adapter.GetDbCount(new JobEntityFactory().CreateFields(), bucket, null, false);
filter.ReturnedMatchesCount = jobs.Count;
tempContext.Clear();
return jobs;
其中存储桶包含大量谓词,例如
bucket.Relations.Add(JobEntity.Relations.JobTypeEntityUsingJobTypeFk);
bucket.Relations.Add(JobTypeEntity.Relations.JobTypeCategoryEntityUsingCategoryFk);
var fieldCompareValuePredicate = new FieldCompareValuePredicate(JobTypeCategoryFields.Filter, null,
ComparisonOperator.Equal, filter.JobCategory) { CaseSensitiveCollation = true };
bucket.PredicateExpression.Add(fieldCompareValuePredicate);
作业实体有一组附件(通过外键)
如何过滤作业列表以仅选择带有一个或多个附件的作业? 我知道我可以通过动态视图使用内存过滤器(AggregateSetPredicate),但这意味着我必须获取所有作业才能获得正确的计数,当前获取的返回计数有最大值。
I currently fetch a collection of jobs like this:
jobs = new EntityCollection<JobEntity>(new JobEntityFactory());
var bucket = GetJobsBucket(filter);
var tempContext = new Context();
tempContext.Add(jobs);
var sorter = new SortExpression(JobFields.Id | SortOperator.Descending);
adapter.FetchEntityCollection(jobs, bucket, maxCount, sorter, JobListPrefetchPath(false));
filter.TotalMatchesCount = adapter.GetDbCount(new JobEntityFactory().CreateFields(), bucket, null, false);
filter.ReturnedMatchesCount = jobs.Count;
tempContext.Clear();
return jobs;
where bucket contains lots of predicates e.g.
bucket.Relations.Add(JobEntity.Relations.JobTypeEntityUsingJobTypeFk);
bucket.Relations.Add(JobTypeEntity.Relations.JobTypeCategoryEntityUsingCategoryFk);
var fieldCompareValuePredicate = new FieldCompareValuePredicate(JobTypeCategoryFields.Filter, null,
ComparisonOperator.Equal, filter.JobCategory) { CaseSensitiveCollation = true };
bucket.PredicateExpression.Add(fieldCompareValuePredicate);
The Job entity has a collection of Attachments (via foreign key)
How can I filter the job list to only select jobs with one or more attachments?
I know I could use a in-memory filter (AggregateSetPredicate) via a dynamic view but this will mean I will have to fetch all the jobs in order to get the correct counts, the current fetch has a maximum on the returned count.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案是这样做:
Solution is to do this: