0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

QueryExpression複数entities項目出力

Posted at
    /// <summary>
    /// ファイル出力QueryExpression組合せ
    /// </summary>
    /// <param name="entityName">対象エンティティ名</param>
    private QueryExpression GetQueryExpression(string entityName)
    {
        // データ検索
        var values = new string[] { "team", "systemuser" };
        var queryExpression = new QueryExpression(_context.LogicName)
        {
            ColumnSet = new ColumnSet("principalobjectaccessid", "principaltypecode", "principalid", "objecttypecode", "objectid", "accessrightsmask"),
            Criteria =
                    {
                        Conditions =
                        {
                            new ConditionExpression("principaltypecode", ConditionOperator.In, values),
                            new ConditionExpression("principalid", ConditionOperator.NotEqual, _context.TSBTeamID),
                            new ConditionExpression("accessrightsmask", ConditionOperator.GreaterEqual, 1),
                            new ConditionExpression("objecttypecode", ConditionOperator.Equal, entityName)
                        },
                    },
        };

        // 共通
        var linkTeam = new LinkEntity
        {
            JoinOperator = JoinOperator.LeftOuter,
            LinkFromEntityName = "principalobjectaccess",
            LinkFromAttributeName = "principalid",
            LinkToEntityName = "team",
            LinkToAttributeName = "teamid",
            EntityAlias = "team",
            Columns = new ColumnSet("name"),
        };

        // 共通
        var linkSystemUser = new LinkEntity
        {
            JoinOperator = JoinOperator.LeftOuter,
            LinkFromEntityName = "principalobjectaccess",
            LinkFromAttributeName = "principalid",
            LinkToEntityName = "systemuser",
            LinkToAttributeName = "systemuserid",
            EntityAlias = "systemuser",
            Columns = new ColumnSet("fullname"),
        };

        // 共通
        var linkOrg = new LinkEntity
        {
            JoinOperator = JoinOperator.LeftOuter,
            LinkFromEntityName = "principalobjectaccess",
            LinkFromAttributeName = "principalid",
            LinkToEntityName = "new_organization",
            LinkToAttributeName = "new_team",
            EntityAlias = "org",
            Columns = new ColumnSet("new_field1", "new_field2", "new_field3"),
        };

        // 共通
        var linkLineTeam = new LinkEntity
        {
            JoinOperator = JoinOperator.LeftOuter,
            LinkFromEntityName = "new_organization",
            LinkFromAttributeName = "new_team_share",
            LinkToEntityName = "team",
            LinkToAttributeName = "teamid",
            EntityAlias = "lineteam",
            Columns = new ColumnSet("name"),
        };

        queryExpression.LinkEntities.Add(linkTeam);
        queryExpression.LinkEntities.Add(linkSystemUser);

        if (_getOrganization)
        {
            linkOrg.LinkEntities.Add(linkLineTeam);
            queryExpression.LinkEntities.Add(linkOrg);
        }

        // 顧客情報出力
        var linkAccount = new LinkEntity
        {
            JoinOperator = JoinOperator.LeftOuter,
            LinkFromEntityName = "principalobjectaccess",
            LinkFromAttributeName = "objectid",
            LinkToEntityName = "account",
            LinkToAttributeName = "accountid",
            EntityAlias = "acct",
            Columns = new ColumnSet("statecode", "new_field1", "new_field2", "new_field3"),
        };

        // 連絡先出力
        var linkCatct = new LinkEntity
        {
            JoinOperator = JoinOperator.LeftOuter,
            LinkFromEntityName = "principalobjectaccess",
            LinkFromAttributeName = "objectid",
            LinkToEntityName = "contact",
            LinkToAttributeName = "contactid",
            EntityAlias = "catct",
            Columns = new ColumnSet("statecode", "new_field1", "new_field2", "new_field3"),
        };

        var catctLinkAccount = new LinkEntity
        {
            JoinOperator = JoinOperator.LeftOuter,
            LinkFromEntityName = "contact",
            LinkFromAttributeName = "parentcustomerid",
            LinkToEntityName = "account",
            LinkToAttributeName = "accountid",
            EntityAlias = "catct_acct",
            Columns = new ColumnSet("statecode", "new_field1", "new_field2", "new_field3"),
        };
        linkCatct.LinkEntities.Add(catctLinkAccount);



        switch (entityName)
        {
            case "account":
                queryExpression.LinkEntities.Add(linkAccount);
                break;
            case "contact":
                queryExpression.LinkEntities.Add(linkCatct);
                break;
            case "new_execution_pipeline":
                queryExpression.LinkEntities.Add(linkPipl);
                break;
            default:
                break;
        }

        return queryExpression;
    }
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?