AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
NAV
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 06.12.2012, 21:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
Danny Varghese: Sample CRM 2011 Retrieve and Retrieve Multiple
Источник: http://varghesedanny.com/2012/12/06/...ieve-multiple/
==============

Thank you to all who have been reading my blog articles and have commented and sent personal messages.  It means a lot to me to know some of my content might be helping.  A common request I get is to post sample code on some basic operations using web services.  I’ll try to do that in the upcoming articles.  For those of you that are seasoned CRM developers, this might be redundant and I apologize!

The method GetCRMService() is a private helper method used to retrieve an instance of the CRM web service using on-premise AD authentication.  The code to authenticate for IFD and even for the Office 365 credentials are different and will be posted in a later article.

private IOrganizationService GetCRMService(){ // Initialize credentials for service authentication ClientCredentials credentials = new ClientCredentials(); credentials.Windows.ClientCredential = new System.Net.NetworkCredential("username", "password", "domain"); // Configure the org uri with the organization service url Uri organizationUri = new Uri("http://servername/orgname/XRMServices/2011/Organization.svc"); IServiceConfiguration config = ServiceConfigurationFactory.CreateConfiguration(organizationUri); // The using statement assures that the service proxy will be properly disposed. using (OrganizationServiceProxy serviceProxy = new OrganizationServiceProxy(config, credentials)) { return serviceProxy; } }An example of retrieve a single record, given the record id is below:

public Entity RetrieveRecord(string entityName, Guid recordId, ColumnSet columns){ return GetCRMService().Retrieve(entityName, recordId, columns);}An example of retrieving multiple records is below:

public IEnumerable RetrieveRecords(string entityName, ColumnSet columns){ QueryExpression query = new QueryExpression { EntityName = entityName, ColumnSet = columns, Criteria = new FilterExpression { Conditions = { new ConditionExpression { AttributeName = "attributeName", Operator = ConditionOperator.Equal, Values = {"attributeValue"} } } }; } return GetCRMService().RetrieveMultiple(query).Entities; }


Источник: http://varghesedanny.com/2012/12/06/...ieve-multiple/
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 8 Blog bot Dynamics CRM: Blogs 1 30.04.2016 10:26
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 11 Blog bot Dynamics CRM: Blogs 0 06.10.2012 05:27
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 10 Blog bot Dynamics CRM: Blogs 0 17.08.2012 03:27
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 7 Blog bot Dynamics CRM: Blogs 0 27.03.2012 02:11
Microsoft Dynamics CRM Team Blog: Create Sample Data for your Solution Blog bot Dynamics CRM: Blogs 0 01.12.2011 05:14

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 07:19.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.