gpt4 book ai didi

c# - 我已经使用 CrmSvcUtil 为 Dynamics CRM 2011 生成了早期绑定(bind)实体类 - 现在怎么办?

转载 作者:行者123 更新时间:2023-11-30 14:14:03 25 4
gpt4 key购买 nike

我已经设置了一个测试 Dynamics CRM 2011 服务器。

我已使用 SDK 的 CrmSvcUtil 实用程序生成早期绑定(bind)实体类(例如 mycrm.cs)。

我在 Visual Studio 中创建了一个新项目并添加了对 Microsoft.CRM.SDK.Proxy、Microsoft.Xrm.Sdk 和 System.Runtime.Serialization 的引用。

我还将 mycrm.cs 文件作为现有文件添加到我的项目中。

现在呢?

我知道,我知道...阅读 SDK。我试过:

Using the Early Bound Entity Classes in Code

Using the Early Bound Entity Classes for Create, Update, Delete

Create Early Bound Entity Classes with the Code Generation Tool (CrmSvcUtil.exe)

如果一定要叫我白痴 - 我敢肯定这些文章可能包含这些信息。我需要,但我没有看到它。帮助!

最佳答案

首先,您需要连接到 CRM 网络服务:

OrganizationServiceProxy orgserv;
ClientCredentials clientCreds = new ClientCredentials();
ClientCredentials devCreds = new ClientCredentials();


clientCreds.Windows.ClientCredential.UserName = "user";
clientCreds.Windows.ClientCredential.Password = "P@$$w0rd";
clientCreds.Windows.ClientCredential.Domain = "myDomain";
IServiceConfiguration<IOrganizationService> orgConfigInfo =
ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(new Uri("https://myCRMServer/myOrg/XRMServices/2011/Organization.svc"));

orgserv = new OrganizationServiceProxy(orgConfigInfo, clientCreds);
orgserv.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());

之后,您将使用您的 XrmServiceContext,或者您在这里的命名方式:

CrmSvcUtil.exe /url:http://servername/organizationname/XRMServices/2011/Organization.svc /out:.cs /username: /password: /domain: /namespace: /serviceContextName:XrmServiceContext

然后您可以从 link you posted 中的 CRUD 示例开始:)

更新联系人的例子:

using(var context = new XrmServiceContext(orgserv))
{
Contact con = context.contactSet.FirstOrDefault(c => c.Name == "Test Contact");
if(con != null)
{
con.City = "NY";

context.UpdateObject(con);
context.SaveChanges();
}
}

希望对您有所帮助:)

关于c# - 我已经使用 CrmSvcUtil 为 Dynamics CRM 2011 生成了早期绑定(bind)实体类 - 现在怎么办?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12940895/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com