2009-03-11 6 views
2

を数える:バケットは、例えば述語が多く含まフィルタリング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); 

仕事エンティティは(外部キー経由)

を添付ファイルのコレクションを持っているどのように私は1つの以上の添付ファイルでのみ選択ジョブにジョブリストをフィルタリングすることができますか? 動的なビューでメモリ内フィルタ(AggregateSetPredicate)を使用することができますが、これは正しいカウントを取得するためにすべてのジョブをフェッチする必要があることを意味し、現在のフェッチでは返されたカウントが最大になります。

答えて

2

ソリューションは、これを行うことです。

bucket.Relations.Add(JobEntity.Relations.AttachmentEntityUsingJobFk); 
FieldCompareSetPredicate filteredAttachments; 
filteredAttachments = new FieldCompareSetPredicate(JobFields.Id, null, 
                AttachmentFields.JobFk, null, 
                SetOperator.In, null); 
bucket.PredicateExpression.Add(filteredAttachments); 
関連する問題