检索具有在不同实体中找到的属性值的实体

retrieve entity with attribute value found in a different entity

例如:我有 3 个实体客户、应用程序和案例。客户表格需要从案例表格中获取开始日期、结束日期并计算日期之间的差异。

来自的案例具有应用程序 ID,该 ID 也存在于客户表单中。我如何从案例中找到的应用程序 ID 获取客户实体并将案例更新到客户的日期?我正在开发一个插件,是否应该有关系或查找字段?当给定实体及其属性值时,可以使用 'Advanced Find' 实现类似的功能 Advance Find 获取所有结果。

非常感谢任何帮助!!

正如 Henk van Boeijen 所说,您可以执行以下操作:

 private void DoFetchXmlToQueryExpressionConversion()
        {
            // Create a Fetch query that we will convert into a query expression.
            var fetchXml =
                @"<fetch mapping='logical' version='1.0'>
                    <entity name='opportunity'>
                        <attribute name='name' />
                        <filter>
                            <condition attribute='estimatedclosedate' operator='next-x-fiscal-years' value='3' />
                        </filter>
                        <link-entity name='account' from='accountid' to='customerid'>
                            <link-entity name='contact' from='parentcustomerid' to='accountid'>
                                <attribute name='fullname' />
                                <filter>
                                    <condition attribute='address1_city' operator='eq' value='Bellevue' />
                                    <condition attribute='address1_stateorprovince' operator='eq' value='WA' />
                                </filter>
                            </link-entity>
                        </link-entity>
                    </entity>
                </fetch>";

            // Run the query with the FetchXML.
            var fetchExpression = new FetchExpression(fetchXml);
            EntityCollection fetchResult =
                _serviceProxy.RetrieveMultiple(fetchExpression);
            Console.WriteLine("\nOutput for query as FetchXML:");
            DisplayOpportunityQueryResults(fetchResult);

            // Convert the FetchXML into a query expression.
            var conversionRequest = new FetchXmlToQueryExpressionRequest
            {
                FetchXml = fetchXml
            };

            var conversionResponse =
                (FetchXmlToQueryExpressionResponse)_serviceProxy.Execute(conversionRequest);

            // Use the newly converted query expression to make a retrieve multiple
            // request to Microsoft Dynamics CRM.
            QueryExpression queryExpression = conversionResponse.Query;

            EntityCollection result = _serviceProxy.RetrieveMultiple(queryExpression);

            // Display the results.
            Console.WriteLine("\nOutput for query after conversion to QueryExpression:");
            DisplayOpportunityQueryResults(result);

        }

来自here

您也可以用类似的方式Linq Query

查找关系名称: 转到系统 > 自定义 > 案例 > 查看关系 (1:N / N:1 / N:N) 找到与您的应用程序正确的关系单击它,查看 > 获取 'Name' 这是架构名称。如果您的查询将此架构名称作为其 link(join),您应该会得到正确的结果。