我有以下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表中插入记录。
在文章管理界面上,我想添加一个链接按钮来抑制/取消压缩文章,方法是添加一个左连接,其中包含两个条件:
左连接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);
非常感谢任何帮助!
答案 0 :(得分:3)
CustomFilter的类型为IPredicateExpression,您创建一个谓词(类型为IPredicate)并将其分配给该属性,这当然不起作用:)
做的:
IRelationCollection relations = new RelationCollection();
relations.Add(ArticleEntity.Relations.SuppressedArticleEntityUsingArticleId, JoinHint.Left)
.CustomFilter = new PredicateExpression(SuppressedArticleFields.OrganizationId == this.CurrentIdentity.OrganizationId);