2

我有以下按类别检索文章的 LLBLGen 代码。本质上,它是从文章表中选择未标记为删除的文章并加入 ArticleTopicCategory 表以检索特定类别(其中 category = 'string')

   ArticleCollection articles = new ArticleCollection();
                IPredicateExpression articlesFilter = new PredicateExpression();
                articlesFilter.Add(ArticleFields.IsFlaggedForDeletion != true);
                PrefetchPath prefetchTopic = new PrefetchPath(EntityType.ArticleEntity);
                prefetchTopic.Add(ArticleEntity.PrefetchPathTopic);
                prefetchTopic.Add(ArticleEntity.PrefetchPathArticleTopicCategories).SubPath.Add(ArticleTopicCategoryEntity.PrefetchPathTopicCategory);
                articles.GetMulti(articlesFilter, prefetchTopic);

我添加了另一个名为 SuppressedArticle 的表,它是一个 1 对多的表,包含 Id、OrganizationId 和 ArticleId。理论上,由于文章被联合到多个网站,如果“网站 A”不想发布“文章 A”,他们可以压制它,即在 SuppressedArticle 表中插入一条记录。

在文章管理屏幕上,我想添加一个链接按钮来抑制/取消抑制文章,方法是添加具有以下两个条件的左连接:

left join SuppressedArticle on (Article.Id = SuppressedArticle.articleId and SuppressedArticle.organizationId='CC177558-85CC-45CC-B4E6-805BDD1EECCC')

我尝试像这样添加多重连接,但我投射/转换错误:

“无法将类型 'SD.LLBLGen.Pro.ORMSupportClasses.FieldCompareValuePredicate' 隐式转换为 'SD.LLBLGen.Pro.ORMSupportClasses.IPredicateExpression'。存在显式转换(您是否缺少演员表?)”

IRelationCollection relations = new RelationCollection();
                relations.Add(ArticleEntity.Relations.SuppressedArticleEntityUsingArticleId, JoinHint.Left).CustomFilter = new FieldCompareValuePredicate(SuppressedArticleFields.OrganizationId, ComparisonOperator.Equal, this.CurrentIdentity.OrganizationId);

任何帮助将不胜感激!

4

1 回答 1

3

CustomFilter 是 IPredicateExpression 类型,您创建一个谓词(IPredicate 类型)并将其分配给该属性,这当然不起作用:)

做:

IRelationCollection relations = new RelationCollection();
relations.Add(ArticleEntity.Relations.SuppressedArticleEntityUsingArticleId, JoinHint.Left)
             .CustomFilter = new PredicateExpression(SuppressedArticleFields.OrganizationId == this.CurrentIdentity.OrganizationId);
于 2010-08-17T16:25:33.897 回答