public static EntityCollection GetUserTeam(IOrganizationService service, Guid userId, Guid businessunitid)
{
try
{
QueryExpression sorgu = new QueryExpression()
{
EntityName = "team",
ColumnSet = new ColumnSet("teamid", "name", "businessunitid"),
Criteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression("businessunitid",ConditionOperator.Equal,businessunitid),
}
},
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName="team",
LinkFromAttributeName="teamid",
LinkToEntityName = "teammembership",
LinkToAttributeName = "teamid",
LinkEntities =
{
new LinkEntity
{
LinkFromEntityName="teammembership",
LinkFromAttributeName="systemuserid",
LinkToEntityName = SystemUser.EntityLogicalName,
LinkToAttributeName = "systemuserid",
LinkCriteria = new FilterExpression
{
FilterOperator = LogicalOperator.And,
Conditions =
{
new ConditionExpression
{
AttributeName = "systemuserid",
Operator = ConditionOperator.Equal,
Values = { userId }
}
}
}
}
}
}
}
};
EntityCollection ec = service.RetrieveMultiple(sorgu);
if (ec != null && ec.Entities.Count > 0)
return ec;
else
return new EntityCollection();
}
catch (Exception ex)
{
FileLogHelper.LoggEx(ex, typeof(CrmManagerStatic), "public static EntityCollection GetUserTeam(IOrganizationService service, Guid userId, Guid businessunitid)" + Environment.NewLine +
"UserId : " + CommonFunction.ToString(userId) + Environment.NewLine +
"BusinessUnitId : " + CommonFunction.ToString(businessunitid));
return new EntityCollection();
}
}
Hiç yorum yok:
Yorum Gönder