gpt4 book ai didi

dynamics-crm - 如何在 LinkEntity 中使用条件和过滤器?

转载 作者:行者123 更新时间:2023-12-04 05:26:37 26 4
gpt4 key购买 nike

我想创建一个 QueryExpression模拟这条SQL语句

select * from A
inner join B on A.b_id=B.ID
where B.Name like "% what ever %"

这就是 FetchXML 的样子
<?xml version="1.0" encoding="UTF-8"?>
<fetch distinct="true" mapping="logical" output-format="xml-platform" version="1.0">
<entity name="A">
<attribute name="ID" />
<attribute name="sce_name" />
<link-entity name="B" alias="ab" to="b_id" from="A">
<filter type="and">
<condition attribute="Name" value="% what ever %" operator="like" />
</filter>
</link-entity>
</entity>
</fetch>

我如何在 QueryExpression 中做到这一点 LinkQuery ConditionsFilters ,我也不想从 开始乙一个 也可能有它的条件。

这是我迄今为止尝试过的
QueryExpression query = new QueryExpression("A");
query.ColumnSet.AllColumns = true;
var link = new LinkEntity()
{
JoinOperator = JoinOperator.Inner,
EntityAlias = "c",
LinkFromEntityName = "A",
LinkToEntityName = "B",
LinkFromAttributeName = "b_id",
LinkToAttributeName = "ID",
};

using (var Service = new OrganizationService("con"))
{
EntityCollection entities = Service.RetrieveMultiple(query);
}

最佳答案

希望这应该是不言自明的。

QueryExpression query = new QueryExpression("a") //Start on A
{
ColumnSet = new ColumnSet(), //Columns to retrieve from A
Criteria = new FilterExpression(LogicalOperator.And) //Conditions for A
{
Conditions =
{
new ConditionExpression()
}
},
LinkEntities =
{
//Link to B
new LinkEntity("a", "b", "aid", "bid", JoinOperator.Inner)
{
Columns = new ColumnSet(), //Columns to retrieve from B
LinkCriteria = new FilterExpression() //Conditions for B
{
Conditions =
{
new ConditionExpression()
}
}
}
}
};

关于dynamics-crm - 如何在 LinkEntity 中使用条件和过滤器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37179893/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com