0

有很多关于如何将记录设置为非活动的示例,但是如何将其设置为活动?

我猜你只是对 State 和 Status 选项集使用不同的值,但它们是什么?

谢谢!

4

2 回答 2

1

我找到了答案。

只需使用此处的正确值替换状态和状态值:

http://msdn.microsoft.com/en-us/library/bb890228.aspx

这段代码为进程使用了​​一个新线程,这并不总是必要的,但你明白了。

ThreadPool.QueueUserWorkItem(new WaitCallback(SetState), (object)new SetStateThreadRequest()
{
    proxy = proxy,
    Request = new SetStateRequest()
    {
        EntityMoniker = new EntityReference(Entity, entity.Id),
        State = new OptionSetValue(0), // <== 0 = Active, 1 = Inactive
        Status = new OptionSetValue(1) // <== 1 = Active, 2 = Inactive (some use -1)
    }
});
于 2012-11-13T10:18:59.303 回答
1

激活 Account 实体的示例:

Account account = new Account();

          // ...

          SetStateRequest req = new SetStateRequest();

          req.EntityMoniker = new EntityReference(Account.EntityLogicalName, account.Id);
          req.State = new OptionSetValue(0);
          req.Status = new OptionSetValue(1);

          service.Execute(req);

有关状态和状态代码,请检查MSDN 上的 Account Entity OptionSet Attribute Metadata

于 2012-11-13T10:22:24.977 回答