我想创建一个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
Conditions
and中做到这一点Filters
,我也不想从B开始,因为A也可能有它的条件。
这是我迄今为止尝试过的
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);
}