<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mohamed Ibrahim Mostafa&#039;s Blog &#187; General Development</title>
	<atom:link href="http://www.mohamedibrahim.net/blog/category/general-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mohamedibrahim.net/blog</link>
	<description>Technical issues, problems, errors, findings &#38; resolutions covering Microsoft Dynamics CRM, software development, Microsoft .NET, C#, VB.NET, Commerce Server, Integration, E-Commerce, Scribe, Online shops and more general technology and consultancy posts.</description>
	<lastBuildDate>Tue, 24 Aug 2010 09:22:45 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Creating, consuming and using Microsoft Dynamics CRM 4.0 Service, Using CRM API and CRM SDK to access CRM database via the webservice</title>
		<link>http://www.mohamedibrahim.net/blog/2010/08/09/creating-consuming-and-using-microsoft-dynamics-crm-4-0-service-using-crm-api-and-crm-sdk-to-access-crm-database-via-the-webservice/</link>
		<comments>http://www.mohamedibrahim.net/blog/2010/08/09/creating-consuming-and-using-microsoft-dynamics-crm-4-0-service-using-crm-api-and-crm-sdk-to-access-crm-database-via-the-webservice/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 13:03:48 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim Mostafa</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[General Development]]></category>
		<category><![CDATA[Microsoft Dynamics CRM]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[CRM]]></category>
		<category><![CDATA[CRM 4.0]]></category>
		<category><![CDATA[CRM Database]]></category>
		<category><![CDATA[CRM Service]]></category>
		<category><![CDATA[Dynamics CRM]]></category>
		<category><![CDATA[Entity]]></category>
		<category><![CDATA[SDK]]></category>
		<category><![CDATA[Web Service]]></category>

		<guid isPermaLink="false">http://www.mohamedibrahim.net/blog/?p=239</guid>
		<description><![CDATA[  
Creating, consuming and using Microsoft Dynamics CRM 4.0 Service, Using CRM API and CRM SDK to access CRM database via the webservice. Custom .NET code to access CRM, create, update (edit), insert, delete, retrieve (return) and retrievemultiple records for system entities and custom entities using both entity objects and dynamic entities. 
This post is a collection of the main methods [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: #1f497d; font-size: 10pt;"> </span> </p>
<p>Creating, consuming and using Microsoft Dynamics CRM 4.0 Service, Using CRM API and CRM SDK to access CRM database via the webservice. Custom .NET code to access CRM, create, update (edit), insert, delete, retrieve (return) and retrievemultiple records for system entities and custom entities using both entity objects and dynamic entities. </p>
<p>This post is a collection of the main methods that you would frequently use in your .NET code (Plugin, Website) that is accessing a dynamics CRM 4.0 system and consuming its CRM services. </p>
<p>The <strong>CrmService</strong> Web service provides a set of methods used to perform the most common operations on system and custom entities. </p>
<p>This collection mainly comes from sevaral pages on MSDN. I just thought it will be useful to have them all together if we need one or more of them. </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;">  </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: &amp;amp;amp; color: #1f497d; font-size: 9.5pt;">The following code shows how to set up the Web service, and how to use the <strong><span style="text-decoration: underline;">Create</span></strong><span style="text-decoration: underline;"> and <strong>Retrieve</strong></span> methods.</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;">  </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p><span style="font-family: Consolas; color: black; font-size: 10pt;"></p>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set up the CRM Service.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmAuthenticationToken token = new CrmAuthenticationToken();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.AuthenticationType = 0; </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.OrganizationName = "AdventureWorksCycle";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmService service = new CrmService();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Url = "<a href="http://%3cservername%3e:%3cport%3e/mscrmservices/2007/crmservice.asmx"><span style="color: #0000ff;">http://&lt;servername&gt;:&lt;port&gt;/mscrmservices/2007/crmservice.asmx</span></a>";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.CrmAuthenticationTokenValue = token;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Credentials = System.Net.CredentialCache.DefaultCredentials;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Create an account entity and assign data to some attributes.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">account newAccount = new account();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">newAccount.name = "Greg Bike Store";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">newAccount.accountnumber = "123456";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">newAccount.address1_postalcode = "98052";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">newAccount.address1_city = "Redmond";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Call the Create method to create an account.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">Guid accountId = service.Create(newAccount);</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">Guid contactId = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Call the Retrieve method to retrieve an existing contact.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">ColumnSet myColumnSet = new ColumnSet();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">myColumnSet.Attributes = new string[] { "firstname" };</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact myContact = (contact) service.Retrieve ("contact", contactId, myColumnSet)</span></pre>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;">  </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: #1f497d; font-size: 12pt;">The following example demonstrates the use of the <strong><span style="text-decoration: underline;">Create</span></strong> method.</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set up the CRM Service.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmAuthenticationToken token = new CrmAuthenticationToken();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"> </pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// You can use enums.cs from the SDK\Helpers folder to get the enumeration </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">//   for Active Directory authentication.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.AuthenticationType = 0; </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.OrganizationName = "AdventureWorksCycle";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmService service = new CrmService();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Url = "<a href="http://%3cservername%3e:%3cport%3e/mscrmservices/2007/crmservice.asmx"><span style="color: #0000ff;">http://&lt;servername&gt;:&lt;port&gt;/mscrmservices/2007/crmservice.asmx</span></a>";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.CrmAuthenticationTokenValue = token;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Credentials = System.Net.CredentialCache.DefaultCredentials;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Create the contact object.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact contact = new contact();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Create the properties for the contact object.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.firstname = "Jesper";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.lastname = "Aaberg";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.address1_line1 = "23 Market St.";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.address1_city = "Sammamish";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.address1_stateorprovince = "MT";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.address1_postalcode = "99999";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.donotbulkemail = new CrmBoolean();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.donotbulkemail.Value = true;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Create the contact in Microsoft Dynamics CRM.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">Guid contactGuid = service.Create(contact);</span></pre>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="color: #1f497d;"><span style="font-size: small;"><span style="font-family: Calibri;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span></span></span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="color: #1f497d;"><span style="font-family: Calibri; font-size: small;"> </span></span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: &amp;amp;amp; color: #1f497d; font-size: 9.5pt;">The following example demonstrates the use of the <strong><span style="text-decoration: underline;">Retrieve</span></strong> method.</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;">  </p>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set up the CRM Service.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmAuthenticationToken token = new CrmAuthenticationToken();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"> </pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">
<pre>// You can use enums.cs from the SDK\Helpers folder to get the enumeration</pre>
<pre>//   for Active Directory authentication</pre>
<p>  </p>
<p></span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.AuthenticationType = 0; </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.OrganizationName = "AdventureWorksCycle";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmService service = new CrmService();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Url = "<a href="http://%3cservername%3e:%3cport%3e/mscrmservices/2007/crmservice.asmx"><span style="color: #0000ff;">http://&lt;servername&gt;:&lt;port&gt;/mscrmservices/2007/crmservice.asmx</span></a>";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.CrmAuthenticationTokenValue = token;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Credentials = System.Net.CredentialCache.DefaultCredentials;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Create the column set object that indicates the properties to be retrieved.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">ColumnSet cols = new ColumnSet();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set the properties of the column set.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">cols.Attributes = new string [] {"fullname"};</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// contactGuid is the GUID of the record being retrieved.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">Guid contactGuid = new Guid("4D507FFE-ED25-447B-80DE-00AE3EB18B84");</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Retrieve the contact.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// The EntityName indicates the EntityType of the object being retrieved.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact contact = (contact)service.Retrieve(EntityName.contact.ToString(), </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">                                             contactGuid, cols);</span></pre>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: &amp;amp;amp; color: #1f497d; font-size: 9.5pt;">The following example demonstrates the use of the <strong><span style="text-decoration: underline;">RetrieveMultiple</span></strong> method.</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;">  </p>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set up the CRM Service.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmAuthenticationToken token = new CrmAuthenticationToken();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"> </pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">
<pre>// You can use enums.cs from the SDK\Helpers folder to get the enumeration</pre>
<pre>//   for Active Directory authentication</pre>
<p>  </p>
<p></span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.AuthenticationType = 0; </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.OrganizationName = "AdventureWorksCycle";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmService service = new CrmService();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Url = "<a href="http://%3cservername%3e:%3cport%3e/mscrmservices/2007/crmservice.asmx"><span style="color: #0000ff;">http://&lt;servername&gt;:&lt;port&gt;/mscrmservices/2007/crmservice.asmx</span></a>";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.CrmAuthenticationTokenValue = token;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Credentials = System.Net.CredentialCache.DefaultCredentials;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Create the ColumnSet that indicates the properties to be retrieved.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">ColumnSet cols = new ColumnSet();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set the properties of the ColumnSet.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">cols.Attributes = new string [] {"fullname", "contactid"};</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Create the ConditionExpression.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">ConditionExpression condition = new ConditionExpression();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set the condition for the retrieval to be when the </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">//    contact's address' city is Sammamish.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">condition.AttributeName = "address1_city";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">condition.Operator = ConditionOperator.Like;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">condition.Values = new string [] {"Sammamish"};</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Create the FilterExpression.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">FilterExpression filter = new FilterExpression();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set the properties of the filter.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">filter.FilterOperator = LogicalOperator.And;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">filter.Conditions = new ConditionExpression[] {condition};</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Create the QueryExpression object.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">QueryExpression query = new QueryExpression();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set the properties of the QueryExpression object.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">query.EntityName = EntityName.contact.ToString();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">query.ColumnSet = cols;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">query.Criteria = filter;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Retrieve the contacts.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">BusinessEntityCollection contacts = service.RetrieveMultiple(query);</span></pre>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="color: #1f497d;"><span style="font-family: Calibri; font-size: small;"> </span></span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: &amp;amp;amp; color: #1f497d; font-size: 9.5pt;">The following example demonstrates the use of the <strong>Update</strong> method.</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;">  </p>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set up the CRM Service.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmAuthenticationToken token = new CrmAuthenticationToken();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"> </pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">
<pre>// You can use enums.cs from the SDK\Helpers folder to get the enumeration</pre>
<pre>//   for Active Directory authentication</pre>
<p>  </p>
<p></span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.AuthenticationType = 0; </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.OrganizationName = "AdventureWorksCycle";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmService service = new CrmService();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Url = "<a href="http://%3cservername%3e:%3cport%3e/mscrmservices/2007/crmservice.asmx"><span style="color: #0000ff;">http://&lt;servername&gt;:&lt;port&gt;/mscrmservices/2007/crmservice.asmx</span></a>";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.CrmAuthenticationTokenValue = token;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Credentials = System.Net.CredentialCache.DefaultCredentials;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Create the contact object.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact contact = new contact();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set the contact object properties to be updated.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.address1_line1 = "34 Market St.";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// The contactid is a key that references the ID of the contact to be updated.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.contactid = new Key();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// The contactid.Value is the GUID of the record to be changed.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.contactid.Value = new Guid("4D507FFE-ED25-447B-80DE-00AE3EB18B84");</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Update the contact.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Update(contact);</span></pre>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: &amp;amp;amp; color: #1f497d; font-size: 9.5pt;">The following example demonstrates the use of the <strong>Delete</strong> method.</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;">  </p>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set up the CRM Service.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmAuthenticationToken token = new CrmAuthenticationToken();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"> </pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">
<pre>// You can use enums.cs from the SDK\Helpers folder to get the enumeration</pre>
<pre>//   for Active Directory authentication</pre>
<p>  </p>
<p></span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.AuthenticationType = 0; </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">token.OrganizationName = "AdventureWorksCycle";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">CrmService service = new CrmService();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Url = "<a href="http://%3cservername%3e:%3cport%3e/mscrmservices/2007/crmservice.asmx"><span style="color: #0000ff;">http://&lt;servername&gt;:&lt;port&gt;/mscrmservices/2007/crmservice.asmx</span></a>";</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.CrmAuthenticationTokenValue = token;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Credentials = System.Net.CredentialCache.DefaultCredentials;</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// contactGuid is the GUID of the record being deleted.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">Guid contactGuid = new Guid("4D507FFE-ED25-447B-80DE-00AE3EB18B84");</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Delete the contact.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// The EntityName indicates the EntityType of the object being deleted.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">service.Delete(EntityName.contact.ToString(), contactGuid);</span></pre>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;"><span style="font-family: &amp;amp;amp; color: #1f497d; font-size: 9.5pt;">For Dynamic Entities: The following sample shows how to create a new entity instance by calling the <strong>CreateEntity</strong> method followed by the <strong>AddObject</strong> method.</span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto;">  </p>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">var contact = crm.CreateEntity("contact");</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Set the string properties.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.SetPropertyValue("firstname", "Allison");</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.SetPropertyValue("lastname", "Brown");</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.SetPropertyValue("emailaddress1", "<a href="mailto:allison.brown@contoso.com"><span style="color: #0000ff;">allison.brown@contoso.com</span></a>");</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Setting an explicit ID value is optional, it can be left unassigned, </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">//    but here it is being explicitly assigned.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">var id = Guid.NewGuid();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">contact.SetPropertyValue("contactid", id);</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// Pass the entity name of the entity being created as the first parameter.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">crm.AddObject("contact", contact);</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">crm.SaveChanges();</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;"> </span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">// The ID value can be retrieved after you have called the SaveChanges method.</span></pre>
<pre class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: black; font-size: 10pt;">var id2 = contact.GetPropertyValue&lt;Guid&gt;("contactid");</span></pre>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="color: #1f497d;"><span style="font-family: Calibri; font-size: small;"> </span></span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="color: #1f497d;"><span style="font-family: Calibri; font-size: small;"> </span></span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="color: #1f497d;"><span style="font-family: Calibri; font-size: small;"> </span></span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;"><span style="font-family: Consolas; color: #1f497d; font-size: 10pt;">These methods have been collected from MSDN mainly from these two locations:  <a href="http://msdn.microsoft.com/en-us/library/cc151016.aspx"><span style="color: #1f497d;">http://msdn.microsoft.com/en-us/library/cc151016.aspx</span></a> and <a href="http://msdn.microsoft.com/en-us/library/ff681571.aspx"><span style="color: #1f497d;">http://msdn.microsoft.com/en-us/library/ff681571.aspx</span></a> </span> </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;">  </p>
<p class="MsoNormal" style="margin: 0cm 0cm 0pt; word-break: break-all;">  </p>
<p></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mohamedibrahim.net/blog/2010/08/09/creating-consuming-and-using-microsoft-dynamics-crm-4-0-service-using-crm-api-and-crm-sdk-to-access-crm-database-via-the-webservice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microsoft Dynamics CRM 4 field level validation using javascript regular expression on client side handling the onChange event to validate and check the value and text of a CRM 4.0 field</title>
		<link>http://www.mohamedibrahim.net/blog/2010/04/14/microsoft-dynamics-crm-4-field-level-validation-using-javascript-regular-expression-on-client-side-handling-the-onchange-event-to-validate-and-check-the-value-and-text-of-a-crm-40-field/</link>
		<comments>http://www.mohamedibrahim.net/blog/2010/04/14/microsoft-dynamics-crm-4-field-level-validation-using-javascript-regular-expression-on-client-side-handling-the-onchange-event-to-validate-and-check-the-value-and-text-of-a-crm-40-field/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 01:21:41 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim Mostafa</dc:creator>
				<category><![CDATA[General Development]]></category>
		<category><![CDATA[Microsoft Dynamics CRM]]></category>
		<category><![CDATA[CRM]]></category>
		<category><![CDATA[Dynamics]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://www.mohamedibrahim.net/blog/?p=184</guid>
		<description><![CDATA[Please note that this post is aimed as showing how to use javascript regular expression field level validation in Microsoft Dynamics CRM. The post does not focus on the many ways of getting a regular expression. The example regular expression below is used for explanation only.
If you want to create validation at field level in [...]]]></description>
			<content:encoded><![CDATA[<p>Please note that this post is aimed as showing how to use javascript regular expression field level validation in Microsoft Dynamics CRM. The post does not focus on the many ways of getting a regular expression. The example regular expression below is used for explanation only.</p>
<p>If you want to create validation at field level in Microsoft Dynamics CRM 4 to check the input value and text of a CRM field in an entity form, you can do this using regular expressions written in javascript code that handles the on change (onChange) event of this field at client side.</p>
<p>Below is an example of a regular expression but you might want to use your own regex value or search online for almost unlimited number of regular expressions that do just about anything.</p>
<p>For example, if you want to validate a CRM 4 field so that only a 4 digit year value starting from year 1980 is entered in the field text box, follow the following steps:</p>
<p>- Open the entity customisation form<br />
- select the field you want to validate using javascript regular expression.<br />
- Click on field properties, events tab and then open the onChange event.<br />
- In the onChange event type the following javascript code (script) to handle the event and implement the field level validation:</p>
<pre>//-----------------------------
//Regular expression ensuring a 4 digit year value is input starting from year 1980.
var reDate =/^(([1]{1}[9]{1}[8-9]{1}\d{1})|([2-9]{1}\d{3}))$/</pre>
<pre>//Check if the input value satisfies the regular expression condition
if (document.crmForm.all.new_yearfieldname.value.search(reDate)==-1)
{//if match failed
alert("Please enter a valid year value. Year value must be four digits starting from the year 1980")
crmForm.all.new_yearfieldname.value = '';
}
//-----------------</pre>
<p>Another way of doing this is as follows;</p>
<pre><span style="font-family: Georgia;">//-----------------------------
var regexS = "^(([1]{1}[9]{1}[8-9]{1}\d{1})|([2-9]{1}\d{3}))$"; 
var regex = new RegExp( regexS ); 
var results = regex.exec( crmForm.all.new_yearfieldname.value);
if( results == null )   
{//if match failed
alert("Please enter a valid year value. Year value must be four digits starting from the year 1980")
crmForm.all.new_yearfieldname.value = '';
}
//-----------------------------</span></pre>
<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mohamedibrahim.net/blog/2010/04/14/microsoft-dynamics-crm-4-field-level-validation-using-javascript-regular-expression-on-client-side-handling-the-onchange-event-to-validate-and-check-the-value-and-text-of-a-crm-40-field/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ajax Update progress screen to block access to form during background server side processes</title>
		<link>http://www.mohamedibrahim.net/blog/2010/04/04/189/</link>
		<comments>http://www.mohamedibrahim.net/blog/2010/04/04/189/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 01:38:21 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim Mostafa</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[General Development]]></category>
		<category><![CDATA[Ajax]]></category>

		<guid isPermaLink="false">http://www.mohamedibrahim.net/blog/?p=189</guid>
		<description><![CDATA[If you are writing an Ajax based .NET web application or web page, there are situations were you might want to block the whole webpage from being accessed while a background or server side process is taking place. So for example if the user clicks submit, you want to make the web page not accessible [...]]]></description>
			<content:encoded><![CDATA[<p>If you are writing an Ajax based .NET web application or web page, there are situations were you might want to block the whole webpage from being accessed while a background or server side process is taking place. So for example if the user clicks submit, you want to make the web page not accessible until the backend server side event handler function finishes and reloads the page.</p>
<p>To do this, you need to do the following:</p>
<p>In the button click event, call the javascript function showprogress (client side &#8211; aspx page code):<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<pre>&lt;asp:Button ID="ApplyFilterButton" runat="server" OnClick="ApplyFilterButton_Click"
OnClientClick="if(Page_ClientValidate())ShowProgress();" Text="Apply Filter"
CssClass="ms-crm-Button" Style="height: 23px" /&gt;</pre>
<p>The show progress function should look something like the following:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<pre>&lt;script type="text/javascript"&gt;
   function ShowProgress() {
document.getElementById('&lt;% Response.Write(PageUpdateProgress.ClientID); %&gt;').style.display = "inline";
        }
&lt;/script&gt;</pre>
<p> The update progress control should look something like this:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<pre>&lt;asp:UpdateProgress ID="PageUpdateProgress" runat="server"
AssociatedUpdatePanelID="PageHiddenPanel" DisplayAfter="50"&gt;
  &lt;ProgressTemplate&gt;
     &lt;div id="progressDiv"
     style="background-position: center center;
     background-image: url(../../Images/progress.gif);
     background-repeat: no-repeat; background-attachment: fixed;
     vertical-align: middle; background-color: #000;
     filter: alpha(opacity=50);"&gt;
            &lt;/div&gt;
            &lt;script type="text/javascript"&gt;
                var targetDiv = document.getElementById("progressDiv");
                targetDiv.style.top = 0;
                targetDiv.style.left = 0;
                targetDiv.style.height = screen.availHeight;
                targetDiv.style.width = screen.availWidth;
            &lt;/script&gt;
        &lt;/ProgressTemplate&gt;
    &lt;/asp:UpdateProgres&gt; </pre>
<p> Hope it helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mohamedibrahim.net/blog/2010/04/04/189/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating and Using Silverlight web.config app settings (Web.config Configuration Applicatioin Settings) or app.config application settings configuration file for Silverlight</title>
		<link>http://www.mohamedibrahim.net/blog/2010/01/27/creating-and-using-silverlight-app-settings-webconfig-configuration-applicatioin-settings-to-change-wcf-service-address-after-deployment-servicereferencesclientconfig-servicereferences-clientconfig/</link>
		<comments>http://www.mohamedibrahim.net/blog/2010/01/27/creating-and-using-silverlight-app-settings-webconfig-configuration-applicatioin-settings-to-change-wcf-service-address-after-deployment-servicereferencesclientconfig-servicereferences-clientconfig/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 21:47:30 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim Mostafa</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[General Development]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Configuraiton]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[ServiceReferences.ClientConfig]]></category>
		<category><![CDATA[Settings]]></category>
		<category><![CDATA[xap]]></category>

		<guid isPermaLink="false">http://www.mohamedibrahim.net/blog/?p=149</guid>
		<description><![CDATA[Post Summary:
This posts explains how to create and use something similar to a silverlight  web.config, App.config and appsettings (or app settings) configuration file for silverlight application. This is based on re-using serviceReference.clientconfig as an appconfig configuration file.
The Problem:
A) configuration application settings (like the one in web.config, appsettings or app settings application configuration file):
This is probably very common. Your [...]]]></description>
			<content:encoded><![CDATA[<p><span style="text-decoration: underline;">Post Summary:</span></p>
<p>This posts explains how to create and use something similar to a silverlight  web.config, App.config and appsettings (or app settings) configuration file for silverlight application. This is based on re-using serviceReference.clientconfig as an appconfig configuration file.</p>
<p><span style="text-decoration: underline;">The Problem:</span></p>
<p><span style="text-decoration: underline;">A) configuration application settings (like the one in web.config, appsettings or app settings application configuration file):</span><br />
This is probably very common. Your silverlight application might well need to have some configuration settings that you can change their values without having to re-build and re-deploy the whole application because of a small change in a connection string or appSetting value. Again, AppSettings in good old web.config files in ASP.net applications were the best solution in this case.</p>
<p><span style="text-decoration: underline;">B) WCF Address (EndPoint address value) change after building:</span><br />
Another reason for wanting to have a configuration file in a silverlight application: Have you ever wanted to change the WCF service address (endpoint address) in your silverlight application after deployment. Imagine that you built a silverlight application and deployed it on your test server. The application was tested and confirmed issues and bug free. Now you want to re-deploy the application to the Live server but the WCF service address (end point address) is different which is probably quite common. It might also be that the address is the same but the port on which the WCF service is listening is different. In this case, you will need to change the value of the WCF endpoint address and re-build. So what happened to configuration files! They are a standard now in all Microsoft environments. </p>
<p><span style="text-decoration: underline;">Problem Summary:</span> The problem is there is no clear web.config file in silverlight as the whole code is compiled into a (.xap) file which any html or aspx page can call.</p>
<p><span style="text-decoration: underline;">Solution:</span></p>
<p>In my silverlight application, I had a connection string value that I need to use in my silverlight application (pass it to the webservice). Hence, I wanted the flexibility to change the WCF endpoint address and the connection string configuration value (or any other application setting). I started looking for a solution but I found that most work arounds were either two long or too complicated. As always, I like simple things and I don&#8217;t like over complications. I have to say though that most if not all work arounds that I found were useful for me to come up with this solution. I am not sure but I believe (and hope) the following solution is unique as I have searched for quite a while to find anyone suggesting this idea but I couldn&#8217;t find any.</p>
<p><strong><span style="text-decoration: underline;">Solution part 1</span>: The simplest way for adding application settings to a silverlight application.</strong></p>
<p>Now since ServiceReferences.ClientConfig is just an xml configuration file, you can actually edit it in visual studio and simply add your application settings.</p>
<p>Your file will look something like this:</p>
<pre>&lt;configuration&gt;
    &lt;system.serviceModel&gt;
        &lt;bindings&gt;
            &lt;basicHttpBinding&gt;
                &lt;binding name="xrmServiceBasicHttp" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647"&gt;
                    &lt;security mode="None"&gt;
                        &lt;transport&gt;
                            &lt;extendedProtectionPolicy policyEnforcement="Never" /&gt;
                        &lt;/transport&gt;
                    &lt;/security&gt;
                &lt;/binding&gt;
            &lt;/basicHttpBinding&gt;
        &lt;/bindings&gt;
        &lt;client&gt;
            &lt;endpoint address="<a href="http://localhost:1234/MyWCFService.svc">http://localhost:1234/MyWCFService.svc</a>" binding="basicHttpBinding"
                bindingConfiguration="xrmServiceBasicHttp" contract="XrmService.IXrmService"
                name="xrmServiceBasicHttp" /&gt;
        &lt;/client&gt;
    &lt;/system.serviceModel&gt;</pre>
<pre><strong>  &lt;appSettings&gt;
    &lt;add key="ConnectionString" value="data source=ABC01;initial catalog=DB01;integrated security=SSPI;persist security info=False;packet size=4096" /&gt;
  &lt;/appSettings&gt;</strong></pre>
<pre>&lt;/configuration&gt;</pre>
<p>Now that you have added your application setting (connection string) to your ServiceReferences.ClientConfig, you need to use it in your silverlight code behind (.xaml.cs) file.</p>
<p>Remember, ServiceReferences.ClientConfig is just an XML file (already said that many times!). Hence, you can write a very simple and straight forward function that parses your ServiceReferences.ClientConfig xml file and returns the appSetting value of your application setting.<br />
A function to return an AppSetting value from your clientconfig file can look something like this:</p>
<pre>private string getAppSetting(string strKey)
        {
            string strValue = string.Empty;
            XmlReaderSettings settings = new XmlReaderSettings();           
            settings.XmlResolver = new XmlXapResolver();
            XmlReader reader = XmlReader.Create("ServiceReferences.ClientConfig");
            reader.MoveToContent();
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element &amp;&amp; reader.Name == "add")
                {
                    if (reader.HasAttributes)
                    {
                        strValue = reader.GetAttribute("key");
                        if (!string.IsNullOrEmpty(strValue) &amp;&amp; strValue == strKey)
                        {
                            strValue = reader.GetAttribute("value");
                            return strValue;
                        }
                    }
                }
            }
            return strValue;</pre>
<pre>        }
Finally in your code, to retrieve the AppSetting value for the appSetting key (ConnectionString) that you created, you can just call the above function like this:</pre>
<p>client.SetConnectionStringAsync(getAppSetting(&#8220;ConnectionString&#8221;));<br />
And One last thing, remember when you create the WCF service client object, don&#8217;t explicitly call the WCF service address, as it is already in your ClientConfig file.</p>
<p>So, just call the end Point Configuration Name (endPointConfigurationName) that you want to use. Just like this:</p>
<p>MyServiceClient client = new MyServiceClient(&#8220;MyServiceBasicHttp&#8221;);</p>
<p>&#8212;&#8212;&#8212;-</p>
<p><strong><span style="text-decoration: underline;">Solution part 2:</span> Changing WCF address and endpoint values in &#8220;ServiceReferences.ClientConfig&#8221;.</strong></p>
<p>Anyway, the first thing we need to do is to understand that &#8220;ServiceReferences.ClientConfig&#8221; that all silverlight applications have and use if they are connecting to a WCF sercvice, is just a simple XML file. Actually, not only an XML file but also a configuration file for the application.</p>
<p>You also need to know that the silverlight xap (*.xap) file that silverlight generates is a simple compressed (zipped) file. For this reason, you actually can rename the file to (something.zip) from (something.xap) and then you can access its content. The content of the xap file includes AppManifes.xaml, your application dlls and most importantly &#8220;ServiceReferences.ClientConfig&#8221;.</p>
<p>Now, when I tried to unzip it, change the content of one of its files and then re-zip it and rename it back to (something.xap), this has corrupted it. My application failed. I am not sure why. This was the case despite the fact that most posts about unpacking, unzipping and re-packaging the .xap file works.</p>
<p>What actually works is the following:<br />
Rename the something.xap file to something.zip file. Open the zip file without unzipping (just double click on it) and then copy the file you want to edit, which in our case is the &#8220;ServiceReferences.ClientConfig&#8221; and paste it in a different location. Edit it and make all the changes you need to it and then copy it and paste back into the something.zip file. Replace the exisitng file there. Now go to something.zip and rename it back to something.xap.</p>
<p>Whatever change you have made should now work.</p>
<p>&#8212;&#8212;&#8212;&#8211;</p>
<p>I hope this helps. I really think it is an effective way to get your AppSetting values.</p>
<p>If you got any questions, please comment below (Kindly don&#8217;t use the contact page for questions on posts please)</p>
<p>Also, please let me know (via a comment below) if you want a copy of this application code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mohamedibrahim.net/blog/2010/01/27/creating-and-using-silverlight-app-settings-webconfig-configuration-applicatioin-settings-to-change-wcf-service-address-after-deployment-servicereferencesclientconfig-servicereferences-clientconfig/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Introduction to LLBLGenPro &#8211; All you need to know to get started with LLBLGen Pro &#8211; Hello World! LLBLGen Pro</title>
		<link>http://www.mohamedibrahim.net/blog/2010/01/18/introduction-to-llblgenpro-all-you-need-to-know-to-get-started-with-llblgen-pro-hello-world-llblgen-pro/</link>
		<comments>http://www.mohamedibrahim.net/blog/2010/01/18/introduction-to-llblgenpro-all-you-need-to-know-to-get-started-with-llblgen-pro-hello-world-llblgen-pro/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 20:13:50 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim Mostafa</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[General Development]]></category>
		<category><![CDATA[business Data]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Data Layers]]></category>
		<category><![CDATA[LLBLGen Pro]]></category>

		<guid isPermaLink="false">http://www.mohamedibrahim.net/blog/?p=139</guid>
		<description><![CDATA[In one of my latest projects, I found the client extensively using LLBL Gen Pro which I have never used before. After few hours of playing around with it, I managed to find my way round it just enough to the level that I need to get the basic functionality working.
Hence, for this reason, I [...]]]></description>
			<content:encoded><![CDATA[<p>In one of my latest projects, I found the client extensively using LLBL Gen Pro which I have never used before. After few hours of playing around with it, I managed to find my way round it just enough to the level that I need to get the basic functionality working.</p>
<p>Hence, for this reason, I thought I will write a post to show the basic and first steps for using LLBL Gen Pro to be used as an introduction by anyone who is, like me few weeks ago, was completely new to LLBLGen Pro.</p>
<p>As it is always the case in most of my posts, I focus on the basic start up functionality straight to the point but if you need further detailed instructions and guides on LLBL Gen Pro then I definitely suggest you start with the online documentation and especially the concepts article. <a href="http://www.llblgen.com/documentation/2.6/Concepts/concepts_entitylistview.htm">http://www.llblgen.com/documentation/2.6/Concepts/concepts_entitylistview.htm</a></p>
<p>For the full LLBL Gen Pro 2.6 Documentation, go to their online user documentation at: <a href="http://www.llblgen.com/documentation/2.6/hh_start.htm">http://www.llblgen.com/documentation/2.6/hh_start.htm</a></p>
<p>The main feature of LLBLGen Pro is that it automatically creates a data layer for any application to use. The data layer provides full access and complete data management DML And DDL features for you allowing complete control of the specified Database.</p>
<p>LLBLGen Pro generates this Data layer for a variety of database types including full support for the following data bases: Firebird, IBM DB2, MS Access, My SQL, Oracle 8,9,10 and 11, Sybase, PostgreSQL and of course almost all Microsoft SQL Server version such as SQL Server 7, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server Express and MSDE drive. wow! You literally don&#8217;t need to write any code, it&#8217;s a full data layer created for you to access any database from any of the above types.</p>
<p>LLBLGen Pro generates the code as a .NET project built in your chosen development language (C# or VB.NET). LLBLGen Pro accesses your database using servername and login id and password in case of DB specific Authentication or just windows authentication if your database allows that. It will then generate the code along with the web.config that already has the connection string to your Database.</p>
<p>Now to use LLBLGen Pro you need to do the following:</p>
<p>First thing to do is obviously to install LLBLGen Pro and add the license file to its installation folder. Next is to run the application from the start menu.</p>
<p>Once LLBLGen is loaded, you need to create a new project. Go to File &#8211;&gt; New project. Fill in the details as follows:</p>
<p>Name: Project name, Create: User, Location: Location where to create the LLBLGen project file.</p>
<p>Select the database driver (database type), database server name and  Authentication type, then hit Connect.</p>
<p>Once connected to the server, you will get the list of available catalogs (DataBases) within this database server.</p>
<p>Select your chosen Database(s) (you can select more than one) and then click Create.</p>
<p>Once you have done that, the project is now created and saved at the selected location.</p>
<p>Next step is to go and add the tables, views and stored procedures. To do this, right click on Entities and click on add new entities mapped on tables. To add views, right click on Entities and add entities mapped on views, and so on.</p>
<p>Once you have added all your tables and views, they will be all created as Entities. i.e. converted to classes in LLBLGen Pro generated code.</p>
<p>Now you got the project ready for generating the code, there are much more detailed configuration that you can do if you want to create complex code, but for most straight forward data layers, this project configuration is enough.</p>
<p>Now go to Project &#8211;&gt; Generate, and you will get the code generation screen. This is where you need to specify the details about the generated code and the project holding it.</p>
<p>The Generate Project Window has 3 tabs. For simplicity and straight forward, not complicated, first project, you only need to fill in the General Settings details. They are the main and most used settings. You can use more complex ones later if you want to.</p>
<p>Target Language: Language to generate the LLBLGen Pro code in (I only tried C#).</p>
<p>Target Platform: Which .NET framework (.NET 3.5 for latest)</p>
<p>Root namespace: Namespace for the generated project</p>
<p>Template Group: Choose self servicing. This is the default and straight forward option in my view.</p>
<p>Destination Root folder: Folder where all generated code files will be created.</p>
<p>Everything is ready now, Click Generate!</p>
<p>Done.</p>
<p>The generated code can be found at the destination root folder specified in the previous step. You will see that the generated code is of type class library. Now go to your solution and add the generated project (Right click on solution &#8211;&gt; add existing Project &#8211;&gt; new LLBL generated project).</p>
<p>Next and final step in this LONG post is to just add another project that you want to use to work with the data layer that LLBLGen Pro has just created for you as a new project.</p>
<p>Using LLBLGen Pro classes is easy and straight forward but this is the subject of another post, if anyone is interested?!</p>
<p>Please comment if you want me to blog on using LLBLGen Pro generated code basics and introduction.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mohamedibrahim.net/blog/2010/01/18/introduction-to-llblgenpro-all-you-need-to-know-to-get-started-with-llblgen-pro-hello-world-llblgen-pro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Post code and Address lookup Using PAF for auto filling address details on websites</title>
		<link>http://www.mohamedibrahim.net/blog/2009/09/02/post-code-and-address-lookup-paf-auto-fill-on-websites/</link>
		<comments>http://www.mohamedibrahim.net/blog/2009/09/02/post-code-and-address-lookup-paf-auto-fill-on-websites/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 09:45:44 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim Mostafa</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[General Development]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[Address]]></category>
		<category><![CDATA[Auto-fill]]></category>
		<category><![CDATA[Lookup]]></category>
		<category><![CDATA[PAF]]></category>
		<category><![CDATA[Royal Mail]]></category>

		<guid isPermaLink="false">http://www.mohamedibrahim.net/blog/?p=94</guid>
		<description><![CDATA[I was recently researching how to implement post code and address look-up on websites and on Microsoft Dynamic CRM. This feature is widely used in auto filling address details when a customer input their post code and sometimes the house number. This is also used in some desktop applications, plug-ins to Microsoft Dynamics CRM, in [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently researching how to implement post code and address look-up on websites and on Microsoft Dynamic CRM. This feature is widely used in auto filling address details when a customer input their post code and sometimes the house number. This is also used in some desktop applications, plug-ins to Microsoft Dynamics CRM, in store locator functions, bank details verification and in applications where the customer inputs their post code and the system can accordingly specifies which region or area the customer falls into. For example, quote websites, i.e. websites offering quotes for nationwide website visitors, will most probably need to know which region the customer is part of so if he is from the North East of England, the server may be much cheaper for example than in London.</p>
<p>After a bit of research, I found out that there several UK post code suppliers. The major supplier is of course as expected Royal Mail. Royal Mail provides a service called <a title="Postcode Address File (PAF)" href="http://www.royalmail.com/portal/rm/content3?mediaId=56000705&amp;catId=400085" target="_blank">Postcode Address File (PAF®)</a>. The problem though is that Royal Mail will not give you any application, they will just give you some raw data on a CD and they will be sending you updates for this data every month, 3 months, 6 months and even some daily changes depending on your choice. The data is great and I think it does have almost all Britain&#8217;s postcode areas and addresses. Regular updates also ensures that the information is up to date. The raw data though needs to be manipulated by an application. Some hard coding will be required which is not too difficult to do but if you are not an experienced developer or have no development background, this will be an issue for you. I will try to address the coding of such functionality in Microsoft .NET (C# and VB.NET) in a later post.</p>
<p>Alternatively, I found out about quite a few online companies that provide solutions for the raw data. So, basically they create web-services which manipulate Royal Mail (PAF ) raw data and all you need to do is to write simple code to return the details you require. So you pass on the post code to them for example and they send you back the full address details. Many of them will even give you example code making your life easier. If you do not need this for a website, you can always opt for their other services such as an online application for you that you can login to and get the address information you require.</p>
<p>Pricing of these post code data providers varies with most of them if not all providing the service using credits. So each credit gives you one address information request. Credits are sold in packs with prices averaging around £50 for 750 credits pack. Do not buy the first one you see, ask around and shop around. Royal Mail though has a different licence structure with prices starting from £85 for a single workstation and £2 for every extract up to £££thousands of pounds for a multi-organisation multi-server licences. </p>
<p>If you need more information, recommendation and links to the best providers of this post code and address information services, please get in touch and I will get back to you. I have now managed to nail down the best providers and got good offer from them. Just get in touch!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mohamedibrahim.net/blog/2009/09/02/post-code-and-address-lookup-paf-auto-fill-on-websites/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Scribe Console: Renaming Source Text files before running a job and after processing and regularly changing source file names.</title>
		<link>http://www.mohamedibrahim.net/blog/2009/08/11/scribe-console-renaming-source-text-files-before-running-a-job-after-processing-and-regularly-changing-source-file-name/</link>
		<comments>http://www.mohamedibrahim.net/blog/2009/08/11/scribe-console-renaming-source-text-files-before-running-a-job-after-processing-and-regularly-changing-source-file-name/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 17:13:06 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim Mostafa</dc:creator>
				<category><![CDATA[General Development]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[DTS]]></category>
		<category><![CDATA[Jobs]]></category>
		<category><![CDATA[SCRIBE]]></category>
		<category><![CDATA[Scribe Console]]></category>
		<category><![CDATA[Scribe CRM Adaptor]]></category>
		<category><![CDATA[Scribe Server]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.mohamedibrahim.net/blog/?p=90</guid>
		<description><![CDATA[Have you ever looked in Scribe Insight for a way to rename a source file before processing it. Scribe console creates collaborations where integration processes can be configured so that they wait for a file to be added to a specific location and then run a specified job. Once the file is added the job will run and process the file. Also, Scribe DTS jobs can only be setup to process a source file that has its name always fixed and unchanged. So a DTS can be setup to process a source file named: customersdata.txt. It will never run if another source file is added to the location the Scribe console is looking at. In this case, if you get a source file with the date (and time) stamp in its name will need to rename it so the the DTS can detect it and run. So if the source file comes with time and date stamp that varies every day (for example: customers_1453_21092009.txt), you will need to rename "customers_1453_21092009.txt" to "customersdata.txt" only to get the DTS to work.]]></description>
			<content:encoded><![CDATA[<p>This post applies for Scribe Insight version 6.5.1. It may well apply to all Scribe version 6.5.x</p>
<p>Have you ever looked in Scribe Insight for a way to rename a source file before processing it. Scribe console creates collaborations where integration processes can be configured so that they wait for a file to be added to a specific location and then run a specified job. Once the file is added the job will run and process the file. Also, Scribe DTS jobs can only be setup to process a source file that has its name always fixed and unchanged. So a DTS can be setup to process a source file named: customersdata.txt. It will never run if another source file is added to the location the Scribe console is looking at. In this case, if you get a source file with the date (and time) stamp in its name will need to rename it so the the DTS can detect it and run. So if the source file comes with time and date stamp that varies every day (for example: customers_1453_21092009.txt), you will need to rename &#8220;customers_1453_21092009.txt&#8221; to &#8220;customersdata.txt&#8221; only to get the DTS to work.</p>
<p>After some research, I found out that you can only do this using pre and post processing commands step of the process. Every integration process has step 2 in it called pre and post processing commands. In this step, you can specify a pre-processing and post-processing commands or scripts. This feature lets you specify a pre and post processing file that can do this renaming for you. Accepted pre and post files are: *.vbs, *.js, *.vbe, *.bat, *.cmd, *.exe, *.com</p>
<p>You will then create a pre-processing script that finds all files that start with &#8220;customers*&#8221; in our example and rename it to customersdata.txt which is the source file name the job is expecting. Post processing can be to rename the file to something else so that you keep a record of processed files.</p>
<p>In step 3 of the Integration process, Scribe also gives you two options (in the form two check boxes) that I find very useful. You can either select to delete the source file after processing or you can select to rename it. So the source file will be processed and renamed to something like customersdata.L1.txt. Unfortunately Scribe doesn&#8217;t give you the choice to choose the new name of the file. Hence, you will need to write a post processing script again for renaming it afterwards if you are after a specific file name.</p>
<p>I&#8217;m not sure if there is any other way of renaming source files (also called event files by Scribe) before processing them or specifying a new name for them after processing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mohamedibrahim.net/blog/2009/08/11/scribe-console-renaming-source-text-files-before-running-a-job-after-processing-and-regularly-changing-source-file-name/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using the Internet Explorer Developer Toolbar with Microsoft Dynamics CRM</title>
		<link>http://www.mohamedibrahim.net/blog/2009/04/07/using-the-internet-explorer-developer-toolbar-with-microsoft-dynamics-crm/</link>
		<comments>http://www.mohamedibrahim.net/blog/2009/04/07/using-the-internet-explorer-developer-toolbar-with-microsoft-dynamics-crm/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 13:20:44 +0000</pubDate>
		<dc:creator>Mohamed Ibrahim Mostafa</dc:creator>
				<category><![CDATA[General Development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[IE Toolbar]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[Toolbar]]></category>

		<guid isPermaLink="false">http://www.mohamedibrahim.net/blog/?p=68</guid>
		<description><![CDATA[If you ever want to know the name of a html element (html element id) you will most probably need Internet Explorer developer toolbar. IE developer Toolbar is a free Microsoft product that you can download from Microsoft&#8217;s download website.
Once you download and install the toolbar, you can view it by clicking at view &#8211;&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>If you ever want to know the name of a html element (html element id) you will most probably need Internet Explorer developer toolbar. IE developer Toolbar is a free Microsoft product that you can download from Microsoft&#8217;s download website.</p>
<p>Once you download and install the toolbar, you can view it by clicking at view &#8211;&gt; Explorer bar &#8211;&gt; IE Developer Toolbar.</p>
<p>From the tool bar viewer, you do a lot of things. One main thing that I personally always need whenever I&#8217;m doing a script (javascript) for Microsoft Dynamics CRM is HTML element name, id, innerHTML, innerText and rest of element&#8217;s attributes, etc..</p>
<p>After opening the IE developer toolbar, click on find &#8211;&gt; select element by click and just go and click on the element you need more information about. You will then get absolutely everything you might need (me thinks!).</p>
<p>I think this is definitely useful in many cases and a lot of JavaScript general coding.</p>
<p>&lt;a href=&#8221;http://www.microsoft.com/downloadS/details.aspx?familyid=E59C3964-672D-4511-BB3E-2D5E1DB91038&amp;displaylang=en&#8221;&gt;Download the toolbar here&lt;a/&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mohamedibrahim.net/blog/2009/04/07/using-the-internet-explorer-developer-toolbar-with-microsoft-dynamics-crm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
