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.

C# Linq LinkEntities get EntityInfo

Last updated at Posted at 2022-06-22
public EntityCollection GetEntityInfo()
{
    DateTime dt = DateTime.Now;
    var today = dt.ToString("yyyy-MM-dd");

    EntityCollection result = _context.Service.RetrieveMultiple(
        new QueryExpression
        {
            EntityName = Account.EntityLogicalName,
            ColumnSet = new ColumnSet(new[] { "name" }),
            NoLock = true,
            Distinct = true,
            LinkEntities = {
                new LinkEntity
                {
                    LinkToEntityName ="new_entity1",
                    LinkFromEntityName ="account",
                    LinkToAttributeName ="account",
                    LinkFromAttributeName ="accountid",

                    EntityAlias =ENTITY1,
                    JoinOperator =JoinOperator.Inner,
                    Columns = new ColumnSet(new[] {"name","detail","response_date"}),
                    LinkCriteria ={
                        Conditions ={
                            new ConditionExpression("possible_flg",ConditionOperator.Equal,false),
                            new ConditionExpression("response_date",ConditionOperator.LessThan,today)
                        }
                    },

                    LinkEntities = {
                        new LinkEntity
                        {
                            LinkToEntityName ="new_entity2",
                            LinkFromEntityName ="new_entity1",
                            LinkToAttributeName ="share",
                            LinkFromAttributeName ="shareid",

                            EntityAlias =ENTITY2,
                            JoinOperator =JoinOperator.Inner,
                            Columns = new ColumnSet(new[] {"createdby", "team", "user", "processid"}),
                            LinkCriteria ={
                                Conditions ={
                                    new ConditionExpression("possibility",ConditionOperator.Null)
                                }
                            }

                        }
                    }
                }
            },
        });
    return result;
}
0
0
1

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?