本文整理汇总了C#中OrganizationService.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# OrganizationService.Delete方法的具体用法?C# OrganizationService.Delete怎么用?C# OrganizationService.Delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrganizationService
的用法示例。
在下文中一共展示了OrganizationService.Delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteProfiles
public override int DeleteProfiles(string[] usernames)
{
//JH
using (OrganizationService service = new OrganizationService(OurConnect()))
{
int deletedProfiles = 0;
foreach(string user in usernames){
ConditionExpression usernameCondition = new ConditionExpression();
usernameCondition.AttributeName = consts.username;
usernameCondition.Operator = ConditionOperator.Equal;
usernameCondition.Values.Add(user);
FilterExpression filter = new FilterExpression();
filter.Conditions.Add(usernameCondition);
QueryExpression query = new QueryExpression(consts.userprofile);
query.ColumnSet.AddColumn(consts.username);
query.Criteria.AddFilter(filter);
EntityCollection collection = service.RetrieveMultiple(query);
service.Delete(consts.userprofile, collection.Entities[0].Id);
deletedProfiles++;
}
return deletedProfiles;
}
}
示例2: DeleteUser
//receives a username string and a "delete all related data" boolean
//returns false if the user does not exist
//returns true if user data was deleted(soft delete, hard delete optional)
public override bool DeleteUser(string username, bool deleteAllRelatedData)
{
//tc
using (OrganizationService service = new OrganizationService(OurConnect()))
{
ConditionExpression usernameCondition = new ConditionExpression();
ConditionExpression deleteCondition = new ConditionExpression();
ConditionExpression appCondition = new ConditionExpression();
usernameCondition.AttributeName = consts.username;
usernameCondition.Operator = ConditionOperator.Equal;
usernameCondition.Values.Add(username);
deleteCondition.AttributeName = consts.deleteduser;
deleteCondition.Operator = ConditionOperator.Equal;
deleteCondition.Values.Add(false);
appCondition.AttributeName = consts.appname;
appCondition.Operator = ConditionOperator.Equal;
appCondition.Values.Add(_ApplicationName);
FilterExpression filter = new FilterExpression();
filter.Conditions.Add(usernameCondition);
filter.Conditions.Add(appCondition);
QueryExpression query = new QueryExpression(consts.useraccount);
query.ColumnSet.AddColumn(consts.username);
query.ColumnSet.AddColumn(consts.deleteduser);
query.Criteria.AddFilter(filter);
EntityCollection collection = service.RetrieveMultiple(query);
if (collection.Entities.Count == 0)
{
return false;
}
else
{
if (!deleteAllRelatedData)
{
collection.Entities[0][consts.deleteduser] = true;
activity(username, "Deleted", true);
service.Update(collection.Entities[0]);
return true;
}
else
{//hard delete
service.Delete(consts.useraccount, collection.Entities[0].Id);
return true;
}
}
}
}