CRM 2011 OrganizationServiceProxy vs OrganizationServiceContext

杀马特。学长 韩版系。学妹 提交于 2020-01-01 04:08:08

问题


I am reading through the MS CRM 2011 SDK docs and see two ways for accessing entities: OrganizationServiceContext or OrganizationServiceProxy.

Why would I choose one method over another? The SDK isn't really clear on design considerations on this point.


回答1:


IOrganizationService is your connection to the CRM system.

In Microsoft Dynamics CRM 2011, the primary Web service accessing data and metadata for your organization is the IOrganizationService Web service.

The class OrganizationServiceContext is used as the base class for the data context which is created when you are using early bound entity classes. See how to Use the Organization Service Context Class. It uses an IOrganizationService as the underlying connection.




回答2:


OrganizationServiceContext contains the LINQ provider for CRM. Using it you can construct LINQ queries instead of using QueryExpression or FetchExpressions which are required if you use IOrganizationService direclty.

crmsvcutil.exe can generate a CRM organization specific class that inherits from OrganizationServiceContext in that case you get properties like ContactSet, AccountSet on the generated class that make it easier to compose queries.

You must have an IOrganizationService isntance to use OrganizationServiceContext.

See http://msdn.microsoft.com/en-us/library/gg328028.aspx for more details.



来源:https://stackoverflow.com/questions/5903422/crm-2011-organizationserviceproxy-vs-organizationservicecontext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!